0

I have generated a new Tabbed Application using storyboards.

So far I have

TabBarController -> FirstViewController -> SecondViewController -> ModalViewController

I'm trying to open the modal view before showing the tabBarController. I added the following code on the AppDelegate.m

showModalView is called from application:didFinishLaunchingWithOptions:;

- (void)showModalView
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    GSLoginViewController *loginView = [storyboard instantiateViewControllerWithIdentifier:@"loginView"];
    [loginView setModalPresentationStyle:UIModalPresentationFullScreen];
    [self.window.rootViewController presentViewController:loginView animated:YES completion:NULL];
}

And here the output I have:

Warning: Attempt to present <ModalViewController: 0x93670d0> on 
<UITabBarController: 0x935d170> whose view is not in the window hierarchy!
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
damienbrz
  • 1,806
  • 2
  • 11
  • 15
  • You can find the answer in [here][1]. [1]: http://stackoverflow.com/questions/11862883/whose-view-is-not-in-the-window-hierarchy – Hasintha Janka Jan 17 '13 at 08:43

1 Answers1

5

You are getting this because your Appdelegate don't know that tabbarcontroller is your root view.You should try something like this.

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

and add your code accordingly.The thing is that you should let the app delegate know tabbarcontroller is the rootviewcontroller.

Suraj K Thomas
  • 5,773
  • 4
  • 52
  • 64