"Unable to monitor event loop"崩溃



我添加了断点,发现它在方法中阻塞

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// init local data
[[PDKeychainBindings sharedKeychainBindings] setObject:@"0" forKey:kNEED_GESTURE_LOGIN];
// register notification to notice switching RootVC
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(switchRootControllerWithType:)
name:kNoti_SwitchRootView
object:nil];
// init the third part SDK
[self setupShareSDK];
[self setupBugly];
[self setupUMeng];
[self setupIQKeyBoard];
[self setupZhugeIOWithOptions:launchOptions];
[self setupTrusfort];   
// register push service
[self setupJPushWithOptions:launchOptions];
[self dealWithRemoteNotification:launchOptions];
// set local flag
[KXUserIntroManager setupFlag];
if (self.remoteNotification) {
if ([AccountStateManager isLogin])
[self.loginNavigationController showGesturePDViewController];
self.window.rootViewController = self.loginNavigationController;
} else { 
self.window.rootViewController = self.launchController;
}
return YES;
}

我也尝试了在stackOverFlow中的方式,在上面的方法中添加了以下代码

NSArray *args = [NSProcessInfo processInfo].arguments;
for(NSString *arg in args){
if ([arg isEqualToString:@"NoAnimations"]) {
[UIView setAnimationsEnabled:false];
}
}

图片链接

它只是初始化一些数据并创建一个通知。

虽然这不是对您的问题的直接回答,但很可能您的问题表明您在主线程上做了太多工作,didFinishLaunchingWithOptions。此方法的主要工作是让开,让运行时启动应用程序。你正在做与此完全相反的事情。

最新更新