在线程中初始化 UITextView - 导致问题
当我尝试在线程中执行时:
UITextView *aDescriptionView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 25, 50)];
我收到此错误:
bool _WebTryThreadLock(bool), 0x2819b0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
这里出了什么问题?我应该怎么办?我必须将其放在单独的线程中,因为它返回给我一个 UIView 对象。
When I am trying to execute in a thread:
UITextView *aDescriptionView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 25, 50)];
I am getting this error:
bool _WebTryThreadLock(bool), 0x2819b0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
What went wrong here? What should I do? I have to have this in a separate thread as it returns me a UIView object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了主线程之外,您不得从任何线程访问 UI。曾经。
You must not access UI from any thread besides the main thread. Ever.