[英]NSThread Error in Objective-C
I am getting this error 我收到此错误
bool _WebTryThreadLock(bool), 0x1b53d0: Tried to obtain the web lock from a thread other than the main thread or the web thread. bool _WebTryThreadLock(bool),0x1b53d0:尝试从主线程或Web线程以外的线程获取Web锁。 This may be a result of calling to UIKit from a secondary thread.
这可能是从辅助线程调用UIKit的结果。 Crashing now...
现在崩溃了...
what is this due to ? 这是什么原因?
Thanks 谢谢
From the limited information you gave, I assume that you create a UIView (or any of it'subclass) from a thread. 根据您提供的有限信息,我假定您从线程创建UIView(或其中的任何子类)。
Try using the following instead: 尝试改用以下内容:
[self performSelectorOnMainThread:<#(SEL)aSelector#>
withObject:<#(id)arg#>
waitUntilDone:<#(BOOL)wait#>];
== edit == ==编辑==
If that's your appDelegate which gets the callback from the thread, try adding a new method besides your callback: 如果那是您的appDelegate从线程获取回调,请尝试在回调之外添加新方法:
- (void) setMyImage:(UIImage*)theImage {
...
myUIImageView.image = theImage;
...
}
and call this from the thread as mentioned above: 并从上述线程中调用此方法:
- (void) callBackWithImage:(UIImage*)imageFromUrl {
[self performSelectorOnMainThread:@selector(setMyImage:)
withObject:imageFromUrl
waitUntilDone:NO];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.