Zap*_*ndr 4 objective-c uitableview nsattributedstring ios
使用NSAttributedString滚动时应用程序确实冻结(当我使用NSString它工作正常),所以有我的方法:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
那里有什么错误吗?或某种方式使att.string更快?
我建议NSAttributedString异步创建一次HTML,并将属性字符串存储在模型中.这样,您就不必在每次重复使用单元格时进行HTML - >属性字符串转换,这在您滚动时会发生很多事情.
| 归档时间: |
|
| 查看次数: |
2791 次 |
| 最近记录: |