开发者

How to eliminate "two-stage rotation" warning?

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...


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.


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.


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

  ...

}


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.


@Maciej Swic's answer helped me a bit.

In my case I had already 2 child for the UITabBarController.

For some strange reason all I need was to put

[self.window makeKeyAndVisible];

after I added the 2 children.


Oliver's answer did the trick for me...it was interesting, though...i had not been having any problems until i added a viewWillAppear:animated method to to the subclassed tabviewcontroller...at that point, everything went haywire, until it was fixed by adding the [super viewWillAppear:animated] statement Oliver suggests...


Had problem with Two-stage animation warning with the following order:

self.window.rootViewController = self.tabBarController;
self.tabBarController.selectedIndex = 0;

But changing the order help me to eliminate the warning.

self.tabBarController.selectedIndex = 0;
self.window.rootViewController = self.tabBarController;

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜