Applications are expected to have a root view controller at the end of application launch

后端 未结 30 1964
野的像风
野的像风 2020-11-22 06:42

I get the following error in my console:

Applications are expected to have a root view controller at the end of application launch

30条回答
  •  借酒劲吻你
    2020-11-22 07:34

    I had the same error when trying to change the first view controller that was loaded in

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    At first I didn't really know where the error was coming from precisely so I narrowed it down and found out what went wrong. It turns out that I was trying to change the display of a view before it actually came on screen. The solution was hence to move this code in the viewcontroller that was giving me trouble from

    - (void)viewDidLoad

    to

    - (void)viewDidAppear:(BOOL)animated

    and the error stopped appearing. My problem specifically was caused by making a UIAlertView show.

    In your case I suggest you check out the code in the tabBarController's active view controller (as it is probably a problem in that view controller). If that doesn't work, try to set the starting settings in the nib file instead of in code - or if you want to do it in code, try moving the code to the tabBarController's active viewcontroller's appropriate method.

    Good luck!

提交回复
热议问题