-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.【创建键盘监听事件,然后操作键盘(弹出、收回),结果在运行程序时出现如下错误(如有知道解决办法的朋友请留言探讨!)】

 *** 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这个问题也可以尝试将其监听处理相关的事件加入到主队列中,看能否解决,欢迎有兴趣的互相探讨。

时间: 2024-08-09 16:13:03

-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.【创建键盘监听事件,然后操作键盘(弹出、收回),结果在运行程序时出现如下错误(如有知道解决办法的朋友请留言探讨!)】的相关文章

android每次运行项目时重新启动一个新的模拟器的解决办法

具体解决办法 1.打开任务管理器,结束adb进 2.此时android console下面会出现错误信息 3.切换到dos下面运行: adb start-server 4.重新run as 搞定

弹出层或者下拉菜单被下面的 层遮挡住了解决办法

弹出层或者下拉菜单被下面的<div>层,或者jquery图片切换屋遮挡住了解决办法.这个一般是屋设置了position属性,如POSITION: relative;解决这个办法在当前层设置z-index都是无效的,即使将弹出层所在父层的z-index设置到999,可弹出层依然会被底下的div遮挡住. 造成这个原因是层的叠加原因,叠加原则中指出,非同辈元素,任意一者或其祖元素拥有动态定位时,同时各自向上寻找动态定位的祖元素,并分别从中拿出具备最高级别的祖元素(或其本身)进行比较.所以根据层的叠加

Jboss AS 7 部署web应用程序时无法初始化spring的bean的解决办法

Jboss AS 7 在部署web应用程序的时候无法初始化spring的bean(在tomcat下边不会出现这个问题) 原因是web应用程序没有导入jboss对spring的支持的jar包 解决方法: 下载 snowdrop-vfs.jar(该文件在jboss-spring-subsystem-as7-nodeps-2.0.0.Final.zip包的module-deployer\org\jboss\snowdrop\main下,jboss-spring-subsystem-as7-nodeps

ASP: Response 对象 错误 &#39;ASP 0251 : 80004005&#39; 解决办法

Response 对象 错误 'ASP 0251 : 80004005' 超过响应缓冲区限制 这种情况一般是因为需要输出的网页内容太大了,由于asp在输入内容到客户的浏览器上之前,会把需要输出的全部内容先输出到缓存区,这个缓存区一般默认大小为4194304,即4MB. 参见:c:\windows\system32\inetsrv\下的metabase.xml文件里的AspBufferingLimit="4194304" 当需要输出的网页内容超过设置的AspBufferingLimit时

Xamarin开发Android时Visual Studio 2012没有智能提示解决办法

Most of the people who work with Xamarin’s Mono for Android in Visual Studio 2012 face a bug where Intellisense doesn’t work for AXML in source view. One of the fix which worked for me is mentioned below. Launch Visual Studio 2012 Open a solution wit

使用maven时出现Failure to transfer 异常的解决办法

> 使用maven时出现Failure to transfer 错误的解决方法 在eclipse里使用maven,连接nexus私服. 添加依赖之后,总是报添加的依赖jar文件找不到,但是在nexus的库里面能找到这个依赖的jar文件,但是在本地的maven库里面找不到,于是我将本地库里面这个依赖对应的文件夹删掉,然后在eclipse里面执行update dependencies.成功解决问题! 右键单击项目->maven->update dependencies. 引起的原因是由于本地

向SDE图层中添加大量数据时,出现ORA-00604以及ORA-01000的解决办法

转自原文 向SDE图层中添加大量数据时,出现ORA-00604以及ORA-01000的解决办法 写了一个小程序,从一个列表中读取坐标串,每个坐标串生成一个IPolygon,然后将这些Polygon添加到一个SDE图层中, 向SDE中添加要素的初始代码类似下面: IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOper

[转]&quot;error while loading shared libraries: xxx.so.x&quot; 错误的原因和解决办法

[转]"error while loading shared libraries: xxx.so.x" 错误的原因和解决办法 http://blog.csdn.net/sahusoft/article/details/7388617 一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared obje

通过ajax访问Tomcat服务器web service接口时出现No &#39;Access-Control-Allow-Origin&#39; header问题的解决办法

问题描述 通过ajax访问Web服务器(Tomcat7.0.42)中的json web service接口的时候,报以下跨域问题: XMLHttpRequest cannot load http://localhost:8080/get-employees-by-name/name/admin. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhos