将UITextView添加到自定义tableViewCell =崩溃 [英] Adding UITextView to custom tableViewCell = Crash

查看:53
本文介绍了将UITextView添加到自定义tableViewCell =崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

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

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"; 
        });

这篇关于将UITextView添加到自定义tableViewCell =崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆