*** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /SourceCache/UIKit_Sim/UIKit-3318.16.14/Keyboard/UIKeyboardTaskQueue.m:374
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d04cf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010cce1bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010d04cd9a +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010c8fe5df -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x000000010bcea006 -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 151
5 UIKit 0x000000010b776106 -[UIKeyboardImpl setDelegate:force:] + 470
6 UIKit 0x000000010ba44a2d -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 929
7 UIKit 0x000000010ba4cb54 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 504
8 UIKit 0x000000010b6bad6c -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 602
9 UIKit 0x000000010b6bbe99 -[UIViewController _presentViewController:withAnimationController:completion:] + 2858
10 UIKit 0x000000010b6bdd81 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
11 UIKit 0x000000010b6bdca5 -[UIViewController presentViewController:animated:completion:] + 229
12 BPMClient 0x000000010b262bd8 __28-[LoginVC doLogin:password:]_block_invoke + 664
13 CFNetwork 0x000000011273f935 __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 155
14 Foundation 0x000000010c92201f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
15 Foundation 0x000000010c861db2 -[NSBlockOperation main] + 98
16 Foundation 0x000000010c844384 -[__NSOperationInternal _start:] + 645
17 Foundation 0x000000010c843f93 __NSOQSchedule_f + 184
18 libdispatch.dylib 0x000000010d8c77f4 _dispatch_client_callout + 8
19 libdispatch.dylib 0x000000010d8afb22 _dispatch_queue_drain + 1417
20 libdispatch.dylib 0x000000010d8af432 _dispatch_queue_invoke + 235
21 libdispatch.dylib 0x000000010d8b1fc1 _dispatch_root_queue_drain + 685
22 libdispatch.dylib 0x000000010d8b35d9 _dispatch_worker_thread3 + 111
23 libsystem_pthread.dylib 0x000000010dc4b637 _pthread_wqthread + 729
24 libsystem_pthread.dylib 0x000000010dc4940d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
后面找到问题所在了:-[UIViewController presentViewController:animated:completion:]这个在跳转的时候应该将其添加到主任务队列中
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:[TabViewController new] animated:YES completion:^{
NSLog(@"登录完成,跳转到主界面");
NSLog(@"else _returnUrl:%@",_returnUrl);
}];
});
然后就没有报错了,(但个人认为对于-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread这个问题还是没有解决!)关于队列这个问题个人水平有限,真正的原因还待深入的研究。或许-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread这个问题也可以尝试将其监听处理相关的事件加入到主队列中,看能否解决,欢迎有兴趣的互相探讨。