NSAttributedString *attributeString=[[NSAttributedString alloc] initWithData:[str dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
查看一下是不是线程的问题,子线程不能更新UI,有些东西看着在主线程,很可能在子线程中运行了。
方法一:
dispatch_async(dispatch_get_main_queue(), ^{
//回到主线程更新
});
方法二:
if ([NSThread isMainThread]) {
NSLog(@"isMainThread");
// 是主线程,直接进行UI操作即可
} else{
NSLog(@"No MainThread");
dispatch_sync(dispatch_get_main_queue(), ^{
// 非主线程,将UI操作切换到主线程进行
});
}
ps:我遇到的是图片加载的时候显示不出来,最终的解决方法是,数据在上个界面加载,然后传递到下个界面显示。