Tried to obtain the web lock from a thread解决方法之一
2013-04-08 16:46
381 查看
项目中一个UIViewController内使用异步线程,异步线程未执行完时pop退出此画面,程序crash。控制台打出错误如下:
Tried to obtain the web lock from a thread other than the main thread...
经调查,发现是由于UIViewController的release方法没有在主线程中调用造成的crash,修改方法如下:
- (oneway void) release {
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
} else {
[super release];
}
}
添加以上代码到UIViewController中,当不在主线程中执行release时,强行回到主线程中执行。
Tried to obtain the web lock from a thread other than the main thread...
经调查,发现是由于UIViewController的release方法没有在主线程中调用造成的crash,修改方法如下:
- (oneway void) release {
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
} else {
[super release];
}
}
添加以上代码到UIViewController中,当不在主线程中执行release时,强行回到主线程中执行。
相关文章推荐
- Tried to obtain the web lock from a thread解决方法之一
- 【解决】iOS开发,更新界面时崩溃,Tried to obtain the web lock from a thread other than the main thread or ……
- Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be
- Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be
- 0xab7dcd0: Tried to obtain the web lock from a thread
- [导入]Unable to get the project ile from the web server错误的解决方法
- Unable to get the project ile from the web server的解决方法
- Unable to get the project ile from the web server错误的解决方法
- Unable to get the project ile from the web server错误的解决方法
- Unable to get the project from the web server. 错误的解决方法
- Tomcat常见问题解决 - The web application appears to have started a thread named [FileWatchdog]
- This application is currently offline. To enable the application, remove the app_offline.htm file from ....解决方法
- VMWare出现文件未能锁定(Failed to lock the file)的解决方法
- Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!解决方法
- apk编译不通过,You may want to manually restart adb from the Devices view. 解决方法。
- chm Navigation to the webpage was canceled解决方法
- 虚拟机vmx打不开Failed to lock the file的解决方法
- svn: Failed to lock the file的解决方法
- The method contains(CharSequence) from the type String refers to the missing type CharSequence错误解决方法
- yum update时候出现Another app is currently holding the yum lock, waiting for it to exit...解决方法