您的位置:首页 > 其它

textView在tableViewcell中复用问题,复用时超链接也出现复用,超链接出现在不该出现的文字上

2015-11-04 16:28 381 查看
说明:标题写的长是方便大家检索到,增加一次性搜索的概率

tableviewcell中有一个textview,textview的超链接识别是打开的,

UIDataDetectorTypeLink,那么大量的cell重用后,超链接出现在不是网址的文字上

解决办法是在赋值text的时候先付给nil清空上一个,然后拼接\u200B在前面

语法如下

Objective C: textView.text = [@"\u200B" stringByAppendingString:message.content];

None of these answers worked for me (iOS8, Swift), the only thing that worked for me was to first set the text to
nil
and then prepend the new text with a non-visibile whitespace unicode character (I chose
\u200B
, which is the ZERO WIDTH SPACE character but any character works):

出处stackoverflow:

http://stackoverflow.com/questions/19121367/uitextviews-in-a-uitableview-link-detection-bug-in-ios-7/19589680#19589680
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: