textView在tableViewcell中复用问题,复用时超链接也出现复用,超链接出现在不该出现的文字上
说明:标题写的长是方便大家检索到,增加一次性搜索的概率
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: