升级到Xcode7后出现没设置rootViewController错误

报错信息如下:
exception:Application windows are expected to have a root view controller at the end of application launch

代码如下:
self.window.rootViewController = self._tabBarController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

升级前都正常使用,升级后报错,求大神

阅读 8.6k
3 个回答

NSArray windows = [[UIApplication sharedApplication] windows];
for(UIWindow *window in windows)
{
NSLog(@"window: %@",window.description);
if(window.rootViewController == nil)
{
UIViewController vc = [[UIViewController alloc]initWithNibName:nil bundle:nil]; window.rootViewController = vc;
}

我得代码

新手上路,请多包涵

同求,8.4没问题,9.0就报错exception:Application windows are expected to have a root view controller at the end of application launch

你确定你的 self._tabBarController 不是 nil ?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题