问题
I have a custom tableview cell, which contains some object UIImageView, UILabel, and a UITextView. All object, except the UITextView works fine, but when I try to change the text on the textView:
myTextView.text = @"Some string";
the app crashes with this error:
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...
Any suggestion is very appreciated. Thanks
回答1:
The error sounds like you are setting the text property from a code block that is not executing on the main thread. Check to make sure that any code you have that modifies UIKit objects does so while on the main thread. Example below:
dispatch_async(dispatch_get_main_queue(), ^{
// Set text here
myTextView.text = @"Some string";
});
来源:https://stackoverflow.com/questions/10309991/adding-uitextview-to-custom-tableviewcell-crash