0
votes

My app has a view controller hierarchy set up like this:

UIViewController
    |
UITabBarController
    |
    UINavigationController
    |  |
    |  UIViewController (*)
    |
    UINavigationController
       |
       UIViewController (*)

Why my UIViewController (*) don't get (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration method?

When my app has a view controller hierarchy set up like this:

UITabBarController
    |
    UINavigationController
    |  |
    |  UIViewController (*)
    |
    UINavigationController
       |
       UIViewController (*)

UIViewController (*) get (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration method.

2

2 Answers

3
votes

This is a view controller containment issue. If you're targeting iOS 5, you can use the new UIViewController methods for containment (see Managing Child View Controllers). Otherwise, you need to forward the rotation messages from your root UIViewController to the UITabBarViewController.

1
votes

All your UIViewControllers inside UITabBarController should support autorotation in order to allow rotation for UITabBarController. Place this code in all UIViewController (*):

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   return YES;
}