I can not understand the rotation mechanism in iOS6

My application has subclasses of view controllers shouldautorotateToInterfaceOrientation . And in this I decide every rotation of the view. This is working correctly. But in iOS6, although I read the documents provided by Apple, I cannot understand this.

My application has a navigation controller as the root view controller. This navigation controller has a tab controller. And in the tab controller there are some view controllers. I want the first view controller (in the tab controller) to be considered only as portrait mode, and the second view controller (in the tab controller) to view both portrait and landscape mode. It works correctly in iOS5. But I do not know how to do this in iOS6. Although I know that a subclass must be supported by InterfaceOrientations, it does not work when rotation occurs. To my surprise, this is called when the view is displayed. How to do what I want?

Thanks for reading.

+5
source share
3 answers

The following link may lead you in the right direction: http://code.shabz.co/post/32051014482/ios-6-supportedorientations-with-uinavigationcontroller

Basically, you need to subclass the UINavigationController and listen for changes to the -supportedInterfaceOrientations its topViewController . There is a sample class that you can download in a blog post, and also explains which code to add.

+8
source

When you use the UINavigationController or UITabbarViewController, the application always does what they say in their methods shouldAutorotate, supportedInterfaceOrientations .

You can add a category to redirect these methods to the controller that they currently display. Like this:

  @implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; } @end 

Similar to UITabbarViewController.

0
source

In my opinion, this is the best explanation I found: http://www.widemann.net/wp-fr/?p=662 , but it is in French.

Maybe this makes sense with google traduction in english

0
source

All Articles