I\'m doing the Facebook integration tutorial, I want to show my MainViewViewController if the user has a valid token for the current state otherwise I want to show LoginView
Sometimes presenting modal view controller from window.rootViewController may produce the same warning & have no effect. Example of such hierarchy of view controllers:
Now calling
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[UIViewController new] animated:YES completion:nil];
will cause this exact warning (tested both on iOS6 & 7 Sim)
Solution: Instead of using rootViewController - use the top one presented by it:
UIViewController *topRootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topRootViewController.presentedViewController)
{
topRootViewController = topRootViewController.presentedViewController;
}
[topRootViewController presentViewController:yourController animated:YES completion:nil];