Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to eliminate "two-stage rotation" warning?

Tags:

xcode

ios

iphone

My window's rootViewController is a UINavigationController Then.. In this navigation controller's rootViewController, I popup a modal view(a UITabBarController)

something like this:

UIWindow
->UINavigationController
-->MyFirstViewController<--In this class I run following code
[self.navigationController presentModalViewController:tabController animated:YES];

Then the debugger warning :Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate

However, if the modal view is not tabController this warning does not appear.

What will this behavior do harm to the application when I popup tabController modal view in a navigation controller?

Or I should find another way to do this?

I found several similar questions on this site, but I don't get it...

like image 962
Matt.Z Avatar asked Jul 09 '11 18:07

Matt.Z


4 Answers

The reason is that you are using a UITabBarController outside of the intended usage of it. It is ONLY intended to be used as a root controller, and should you need something similiar to a tabbar use toolbar. I was running into trouble with the exact problem about a half year ago. You will also run into other problems if you use it like that, unfortunately.

UITabBarController documentation

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

like image 150
LuckyLuke Avatar answered Nov 01 '22 02:11

LuckyLuke


This will also happen if you only add a blank UITabbarController without any child controllers, like so:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    //Tab bar controller
    UITabBarController* tabBarController = [[UITabBarController alloc] init];    
    [[self window] setRootViewController:tabBarController];

    [self.window makeKeyAndVisible];
    return YES;
}

The warning will go away if you add a child view controller to the UITabBarController before declaring it the rootViewController of your UIWindow.

like image 29
Maciej Swic Avatar answered Nov 01 '22 02:11

Maciej Swic


I got the same warning when subclassing UITabBarController but forgetting to call the base class's viewWillAppear: method in my own class.

- (void) viewWillAppear:(BOOL)animated {

  [super viewWillAppear:animated]    // <--- adding this fixed the warning

  ...

}
like image 12
Oliver Avatar answered Nov 01 '22 04:11

Oliver


I have an app where a UITabBarController is the root view controller. Depending on an in-app purchase, the child view controllers are different.

In my NIB, I had the UITabBarController without any child view controllers. I added the child view controllers in application:didFinishLaunchingWithOptions:

This caused the warning "two-stage" rotation to appear. As soon as I added one single child view controller to the tabbar controller in the NIB it disappeared.

like image 2
Klaus Thul Avatar answered Nov 01 '22 04:11

Klaus Thul