简体   繁体   中英

Presenting a modal view from a UITabBarController

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM