当我构建我的应用程序时,它可以编译而没有任何问题或错误。但是,当我运行它时,我会在控制台中看到以下消息:
Application windows are expected to have a root view controller at the end of application launch.
这是我的Appdelegate的方法,我认为可能是造成这种情况的原因(基于我在SO上看到的其他帖子)
- (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];
PhotosViewController *viewController = [[PhotosViewController alloc] initWithNibName:nil bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.window addSubview:self.navigationController.view];
[self.window makeKeyAndVisible];
return YES;
这是我需要担心的事情吗?即使出现此消息,我的应用程序仍在模拟器中运行。
关于我应该怎么做才能摆脱它的任何建议?我该如何调试?
顺便说一句,我在SO上也看到了其他问题,并带有类似的错误消息,但是,没有一种情况适用于我,因此我已发布了此问题。它不是重复的:)
谢谢
最佳答案
代替:
[self.window addSubview:self.navigationController.view];
采用:
self.window.rootViewController = self.navigationController;
您可以在
UIWindow
documentation中找到更多详细信息
关于iphone - iOS : Getting this message (not an error) on console- Application windows are expected to have a root view controller at the end of application launch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12344950/