Search code examples
iosuiviewuiviewcontrolleraugmented-realityuiinterfaceorientation

Can a UIView "ignore" interface orientation?


I have a UIView associated with it's own UIViewController that I want to always be locked to portrait mode.

Imagine that it wants to act like a window into the internals of the iPhone. Weird, I know.

That view will have subviews on top of it, or perhaps other viewcontrollers' views which want to respond appropriately to interface rotation. I basically want to lock a single view to portrait while letting my implementation of shouldAutoRotateToInterfaceOrientation handle the rest.

Is there a way to do this?


Solution

  • I believe adding it as a subview of the main window will prevent it from being autorotated (because only UIViewControllers handle rotation). Calling [self.view.window addSubview:internalView]; should work perfectly. (though there are no guarantees as to what orientation the view is in when it is added).