you are calling a UIKit method that can only be invoked from the UI thread.
2014-03-04 16:59
453 查看
mono touch开发时长遇到这样的错误: you are calling a UIKit method that can only be invoked from the UI thread.
这是因为,你的代码涉及到MonoTouch.UIKit库中对象,必须通过UI主线程InvokeOnMainThread来处理才行,类似下面的代码段:
有时候在并行编程中,通过ui主线程来处理并不能够奏效,这时候需要通过禁用UI线程,这样就不会出错:
这是因为,你的代码涉及到MonoTouch.UIKit库中对象,必须通过UI主线程InvokeOnMainThread来处理才行,类似下面的代码段:
using(var pool = new NSAutoreleasePool()) { this.InvokeOnMainThread(delegate { //... }); }
有时候在并行编程中,通过ui主线程来处理并不能够奏效,这时候需要通过禁用UI线程,这样就不会出错:
var previous = UIApplication.CheckForIllegalCrossThreadCalls; UIApplication.CheckForIllegalCrossThreadCalls = false; //.... UIApplication.CheckForIllegalCrossThreadCalls = previous;注意哦,在mono touch中,UI主线程检查是可选的,并且可以被禁用,无论是全局或局部。
相关文章推荐
- unity报“GetLocalizedString can only be called from the main thread.”错误。
- tomcat启动时出现There are no resources that can be added or removed from the server.
- calledfromwrongthreadexception only the original that created a view hierarchy can touch its views
- There are no resources that can be added or removed from the server. .
- dialog子线程操作UI异常:Only the original thread that created a view hierarchy can touch its views
- Error: CompareBaseObjectsInternal can only be called from the main thread
- Eclipse 报错There are no resources that can be added or removed from the server
- There are no resources that can be added or removed from the server Tomcat
- There are no resources that can be added or removed from the server
- 错误:Only the original thread that created a view hierarchy can touch its views——Handler的使用&用其更新UI
- Eclipse There are no resources that can be added or removed from the server.
- Myeclipse2016 部署webapp 至 tomcat 上出现 “There are no resources that can be added or removed from the server”
- Work 工作子线程更新UI控件--解决Only the original thread that created a view hierarchy can touch its views
- <<< Tomcat 部署项目There are no resources that can be added or removed from the server
- unity DestroyBuffer can only be called from the main thread
- There are no resources that can be added or removed from the server.
- eclise 部署web工程报 There are no resources that can be added or removed from the server. 解决办法
- -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.【创建键盘监听事件,然后操作键盘(弹出、收回),结果在运行程序时出现如下错误(如有知道解决办法的朋友请留言探讨!)】
- eclise 部署web工程报 There are no resources that can be added or removed from the server.
- tomcat添加项目(Add and Remove...)出现There are no resources that can be added or removed from the server