Adding UITextView to custom tableViewCell = Crash

怎甘沉沦 提交于 2021-02-08 11:57:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!