美文网首页
[UIApplication _runWithMainScene

[UIApplication _runWithMainScene

作者: 陈长见 | 来源:发表于2017-09-14 16:23 被阅读26次

原来项目好好的, 忽然真机运行后出现这个错误, 百度了一下, 有人是在模拟器出现的这个问题, 而我的是在真机上

网上有人对这个错误的原因有解释

原因:新的SDK不允许在设置rootViewController之前做过于复杂的操作,导致在didFinishLaunchingWithOptions 结束后还没有设置rootViewController
Xcode7需要所有UIWindow必须立即先设置一个rootViewController

我的代码:

UINavigationController *rootViewController = [[UINavigationController alloc] initWithRootViewController:[[JSMainViewController alloc] init]];
self.window.rootViewController = rootViewController;

这个JSMainViewController 是一个UITabBarController

我的具体情况是: 公司要求加入一个检查版本的接口, 这个接口加在了JSMainViewController里, 这个JSMainViewController加载检查接口和他的子控制器写在了一起, 当真机运行时,由于不小心,我自己不知道什么时候关闭了蜂窝网, 我的真机没有打开网络

这时加载检查接口就非常的耗时, 继而在didFinishLaunchingWithOptions 结束后还没有设置rootViewController,导致最终程序崩溃

所以, 如果你是真机运行也报这个错误闪退, 你可以检查下你的移动蜂窝网络是否打开

相关文章

网友评论

      本文标题:[UIApplication _runWithMainScene

      本文链接:https://www.haomeiwen.com/subject/nwmrsxtx.html