0

I have a problem with my app. I would like lock rotation on specific view. For that, I use rootviewcontroller which contain two custom viewControllers. I have try to override the shouldAutorotateToInterfaceOrientation method on my two viewcontrollers but if I allow all rotation on my rootViewController, all my viewcontrollers can rotate like my rootviewcontroller and I don't understand why.

Actually I use this configuration :

RootviewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    //By default, i allow all rotation
   return YES
}

FirstCustomviewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    //On my first viewController, I allow only orientation in portrait
   return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

But in all case, it allow all rotation (I think it come from rootviewcontroller) and why I can't override this method ? What can I do for that ?

Thanks

tryp
  • 1,120
  • 20
  • 26
  • it is not a good practice to do it. :( you should support the available orientations for all individual `UIViewController` what you push into your application... just for your users' sake. :) – holex Aug 01 '12 at 13:52

1 Answers1

1

RootViewController and FirstCustomViewController relations is exactly push-view or modal-view? If a relations is push-view, all sub-view rotation is rely on the root-view.

Think of a UINavigationController as a house and UIViewControllers as rooms. All the rooms in the house will rotate in the same way the house. There is no way to turn a room without turning the house and other rooms.

bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
  • Thank you for your answer. You are true, I don't use modal-view, and it's why I have this problem. With your explication I know why and were is my error. I will use modal view. Thanks a lot – tryp Aug 01 '12 at 14:02