iOS6: do we have to set rootViewController in App delegate in order to support different orientations?

Posted by Centurion on Stack Overflow See other posts from Stack Overflow or by Centurion
Published on 2012-10-10T09:19:13Z Indexed on 2012/10/10 9:37 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

The app was perfectly fine working in iOS5 in landscape orientation. However in iOS6, it started to use portrait orientation in all view controllers. The methods shouldAutorotateToInterfaceOrientation are not called anymore. I read the new stuff about changed rotation mechanism in iOS6 and I was able to fix that by adding a line in my AppDelegate:

self.window.rootViewController = _viewController

_viewControler is the starting screen (Home-menu). All other view controllers implement shouldAutorotateToInterfaceOrientation method and returns YES for landscape orientations only. So, it's perfectly working solution for the app that needs to support only one orientation.

However, the problem is I need one view controller (lets call it phone-VC) to be presented in portrait orientation. Now, if I want this view controller would be rotated then I need to return YES in Home-menu controller that is assigned to rootViewControler in appDelegate. However, I can't do that because this rootViewController is starting window that need to presented in landscape only, otherwise the layout with graphics in this window will break. But if I don't return YES from its shouldAutorotateToInterfaceOrientation (Home-menu) then the same method is not called in my view phone-VC that needs to be presented in portrait.

Any ideas? Does the assignation of rootViewController is mandatory in AppDelegate?

UPDATE: the problem exists on device (at least on iPhone4).

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c