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

后端 未结 30 1302
野的像风
野的像风 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:36

    Try to connect IBOutlet of tab bar controller to root view in the Interface Builder instead of

    self.window.rootViewController = self.tabBarController;
    

    But actually I haven't seen such error before.

    0 讨论(0)
  • 2020-11-22 07:36

    I was able to set the initial view controller on the summary screen of xcode.

    Click on the top most project name in the left hand file explorer (it should have a little blueprint icon). In the center column click on your project name under 'TARGETS', (it should have a little pencil 'A' icon next to it). Look under 'iPhone / iPod Deployment Info' and look for 'Main Interface'. You should be able to select an option from the drop down.

    0 讨论(0)
  • 2020-11-22 07:38

    I came across the same issue but I was using storyboard

    Assigning my storyboard InitialViewController to my window's rootViewController.

    In

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    ...
    UIStoryboard *stb = [UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil];
    self.window.rootViewController = [stb instantiateInitialViewController];
    return YES;
    }
    

    and this solved the issue.

    0 讨论(0)
  • 2020-11-22 07:39

    With my first view being MenuViewController I added:

    MenuViewController *menuViewController = [[MenuViewController alloc]init];
    self.window.rootViewController = menuViewController;
    

    on the App Delegate method:

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

    That worked.

    0 讨论(0)
  • 2020-11-22 07:40

    I also had this error but unlike any of the answers previously listed mine was because i had uncommented the method 'loadView' in my newly generated controller (xcode 4.2, ios5).

     //Implement loadView to create a view hierarchy programmatically, without using a nib.
    - (void)loadView  
    {
    }
    

    It even told me that the method was for creating the view programmatically but i missed it because it looked so similar to other methods like viewDidLoad that i normally use i didn't catch it.

    To solve simply remove that method if you are not programmatically creating the view hierarchy aka using nib or storyboard.

    0 讨论(0)
  • 2020-11-22 07:41

    I upgraded to iOS9 and started getting this error out of nowhere. I was able to fix it but adding the below code to - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    NSArray *windows = [[UIApplication sharedApplication] windows];
    for(UIWindow *window in windows) {
        if(window.rootViewController == nil){
            UIViewController* vc = [[UIViewController alloc]initWithNibName:nil bundle:nil];
            window.rootViewController = vc;
        }
    }
    
    0 讨论(0)
提交回复
热议问题