0
votes

I checked the various answers here and could not find one which works. I have a regular TabBarController based application. I want to show a login screen at launch. What I did was

  • Subclassed UITabBarController and implemented the following in the viewDidAppear:

    LoginViewController *controller = (LoginViewController *)[[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"LoginVC"]; [self presentViewController:controller animated:YES completion:nil];

Once this runs there are 2 things happening : 1. The login view never shows up 2. The log has this : Warning: Attempt to present on whose view is not in the window hierarchy!

What am I missing?

1
Is your new subclass set as the window's rootviewcontroller?Austen Chongpison
I updated the storyboard to say that the UITabBarController is MyTabBarController. Yes from application:didFinishLaunchingWithOptions : (lldb) po self.window.rootViewController <MyTabBarController: 0x7f937966fd10>user3570727
Hmnn.. in the story board it says Tab Bar Controller. If I go to the inspector and check the custom class it says MyTabBarControlleruser3570727
Take a look at the solutions presented here:stackoverflow.com/questions/15287678/…Austen Chongpison
nothing there actually worked.. the only idea i got from there is that the UITabBarController may not be the right place to show the view, as the first view controller in the tabbarcontroller may not be ready, so I moved the code to the first ViewController the TabBarController shows, but that shows : 2014-09-30 16:46:36.753 myapp[45844:3321157] Presenting view controllers on detached view controllers is discouraged <FirstViewController: 0x7fc89c81a9e0>. 2014-09-30 16:46:37.329 myapp[45844:3321157] Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x7fc89c812c50>.user3570727

1 Answers

0
votes

rdelmar answer fixed the warning, that is do the presentation in the viewDidAppear. Thanks!