0

我有一个自定义表格视图单元格,其中包含一些对象 UIImageView、UILabel 和一个 UITextView。除了 UITextView 之外的所有对象都可以正常工作,但是当我尝试更改 textView 上的文本时:

 myTextView.text = @"Some string"; 

应用程序因此错误而崩溃:

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...

任何建议都非常感谢。谢谢

4

1 回答 1

2

该错误听起来像是您正在从未在主线程上执行的代码块中设置 text 属性。检查以确保您拥有的任何修改 UIKit 对象的代码都在主线程上执行此操作。下面的例子:

dispatch_async(dispatch_get_main_queue(), ^{
            // Set text here
            myTextView.text = @"Some string"; 
        });
于 2012-04-25T05:58:19.320 回答