预期具有根视图控制器控制台的应用程序

预期具有根视图控制器控制台的应用程序

本文介绍了预期具有根视图控制器控制台的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的应用程序时,我在控制台中收到一条消息:

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] 应用程序应在应用程序启动结束时具有根视图控制器

我从其他人那里听说这与 didFinishLaunchingWithOptions

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.

我的方法代码:

- (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;
}

推荐答案

你应该更换

[window addSubview:tabBarController.view];

[self.window setRootViewController:tabBarController];

也许您使用 'Empty Application' 构建了您的项目,却忘记在您的 didFinishLaunchingWithOptions 中设置 rootViewController(它存在于您的 AppDelegate.m).

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

但是,如果您使用 'Single View Application' 或其他类型构建项目,则项目将通过 xib 设置 rootViewController默认情况下(可能是您项目中的 MainWindow.xib).

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).

这篇关于预期具有根视图控制器控制台的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:03