2012-04-25 43 views
0

我有一个自定义的tableview单元格,其中包含一些对象UIImageView,UILabel和UITextView。所有对象,除了UITextView的工作正常,但是当我试图改变TextView的文本:将UITextView添加到自定义tableViewCell =崩溃

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

任何建议非常赞赏。 谢谢

+1

它似乎是你试图从辅助线程更新文本,是这种情况?你能添加更多的代码吗? – rishi 2012-04-25 05:55:19

+0

使用performSelectorOnMainThread(NSObject方法)来更新您的UITextView – Niko 2012-04-25 06:00:44

回答

2

错误听起来像你正在设置从主线程上执行的代码块的文本属性。检查以确保在主线程上有任何修改UIKit对象的代码。下面的例子:

dispatch_async(dispatch_get_main_queue(), ^{ 
      // Set text here 
      myTextView.text = @"Some string"; 
     }); 
+0

Thx,工作。 – BlackMouse 2012-04-25 06:09:01