Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applications expected to have a root view controller console

I am getting a message within the console when I run my app that says:

2011-11-16 19:17:41.292 Juice[8674:707] Applications are expected to have a root view controller at the end of application launch

I have heard from others that this has to do with the method didFinishLaunchingWithOptions

If anyone has any suggestions for why I am getting this error, it would be much appreciated.

My code for the method:

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

    // Override point for customization after application launch.

    [window addSubview:tabBarController.view];
    [window makeKeyAndVisible];

    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];

    return YES;
}
like image 796
Teddy13 Avatar asked Nov 18 '11 23:11

Teddy13


3 Answers

You should replace the

[window addSubview:tabBarController.view];

to

[self.window setRootViewController:tabBarController];

Maybe you built your project with 'Empty Application' and forgot to set the rootViewController in your didFinishLaunchingWithOptions (which exists in your AppDelegate.m).

However, if you build your project with 'Single View Application' or some other type, the project will set the rootViewController via xib by default (which might be a MainWindow.xib in your project).

like image 165
Kjuly Avatar answered Sep 28 '22 03:09

Kjuly


I had the same problem on iOS 5, after adding a storyboard to an "empty" project. It turns out I had to remove all the lines in AppDelegate.m that set values to self.window.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    //self.window.backgroundColor = [UIColor whiteColor];
    //[self.window makeKeyAndVisible];
    return YES;
}
like image 29
Frank Avatar answered Sep 28 '22 03:09

Frank


If you have MainWindow.xib, make sure you set Main Interface in Target's summary to MainWindow.

like image 37
anja Avatar answered Sep 28 '22 02:09

anja