NSAttributedString 冻结 UITableView [英] NSAttributedString freeze UITableView
本文介绍了NSAttributedString 冻结 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 NSAttributedString 滚动时应用程序真的冻结(当我使用 NSString 时它工作正常),所以我的方法是:
Application really freeze while scrolling with NSAttributedString (When I use NSString it works fine), so there my method:
- (void)setSubtitleForCell:(TTTableViewCell *)cell item:(TTPhotoPost *)item
{
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:
[item.caption dataUsingEncoding:NSUnicodeStringEncoding]
options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
documentAttributes:nil
error:nil];
[cell.descriptionLabel setAttributedText:attributedString];
}
有什么错误吗?或某种方式使 att.string 更快?
Any mistakes there? or some way to make att.string faster?
推荐答案
我建议从 HTML 异步创建一次 NSAttributedString
,并将属性字符串存储在您的模型中.这样您就不必在每次重复使用单元格时执行 HTML -> 属性字符串转换,这在您滚动时经常发生.
I'd suggest creating the NSAttributedString
from HTML once asynchronously, and storing the attributed string in your model. That way you won't have to do the HTML -> attributed string conversion on every cell reuse, which happens a lot when you're scrolling.
这篇关于NSAttributedString 冻结 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文