2012-04-25 71 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