不知道为什么 当我的xcode升级8.0之后 然后最近有个需求是程序启动前要调用黑名单 我这边处理之后 但是会崩掉 崩溃日志会打印
*** Assertion failure in -[UIApplication
_runWithMainScene:transitionContext:completion:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3599.6/UIApplication.m:3679
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
libc++abi.dylib: terminate_handler unexpectedly threw an exception
刚开始我也是一脸懵逼,网上谷歌 也找不到原因。 最后问了公司的组长 解决了问题
解决办法:
//iOS9.0以后 苹果避免在进行跟试图之前 有复杂的操作 所以先设置一个空的跟试图
self.window.rootViewController = [[UIViewController alloc] init];
加上这一句就可以了
- (void)blackList{
//iOS9.0以后 苹果避免在进行跟试图之前 有复杂的操作 所以先设置一个空的跟试图
self.window.rootViewController = [UIViewController new];
NSString *phone = [[AppManager manager]getMyPhone];
NSDictionary *head = @{@"tradeCode" : @"0046",
@"tradeType" : @"appService"};
NSDictionary *body = @{@"mobilePhone" : phone};
[[AFNetManager manager] postRequestWithHeadParameter:head
bodyParameter:body
success:^(ResponseModel *object) {
//成功 在白名单内
LoginViewController *login = [[LoginViewController alloc]init];
Nav *navigation = [[Nav alloc]initWithRootViewController:login];
[self.window setRootViewController:navigation];
MainTabBarController *main = [[MainTabBarController alloc]init];
[main.tabBarController setSelectedIndex:1];
[login presentViewController:main.tabBarController
animated:NO
completion:nil];
} fail:^(ErrorModel *error) {
LoginViewController *login = [[LoginViewController alloc]init];
Nav *navigation = [[Nav alloc]initWithRootViewController:login];
[self.window setRootViewController:navigation];
}];
}
#pragma mark - 打开App
- (void) openApp {
if ([[AppManager manager] isOnline]) {
//调用黑名单
[self blackList];
} else {
LoginViewController *login = [[LoginViewController alloc]init];
Nav *navigation = [[Nav alloc]initWithRootViewController:login];
[self.window setRootViewController:navigation];
}
}