NSAttributedString
에 HTML 텍스트를 할당합니다. 이 속성 문자열은 UitableViewCell in cellForRowAtIndexPath Method
에있는 UILabel 중 하나에 지정됩니다.
셀 재사용으로 인해 initWithData: method is causing sluggishness at UI
.
따라서 글로벌 큐에서 실행할 코드를 만들었습니다. 나는 이런 식으로 뭔가를하고 있어요 :NSAttributedString에 HTML 텍스트를 할당하면 EXC_BAD_ACESS가 글로벌 큐에 throw됩니다.
-(void)assignAttrText:(NSDictionary *)dict{
NSDictionary *msgThreadDict = [dict objectForKey:@"messgDict"];
__block DRMessageThreadTableViewCell *cell = [dict objectForKey:@"cell"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSError *err = nil;
NSAttributedString *attributedString =
[[NSAttributedString alloc]
initWithData: [[msgThreadDict objectForKey:@"text"] dataUsingEncoding:NSUTF8StringEncoding]
options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
documentAttributes: nil
error: &err];
if(err){
NSLog(@"Unable to parse label text: %@", err);
}
else{
cell.messageTextLabel.attributedText = attributedString;
}
});
단서를 응용 프로그램을 일으키는 것과 같은 방법에 EXC_BAD_ACCESS
와 충돌 : 다음,
[[NSAttributedString alloc]
initWithData: [[msgThreadDict objectForKey:@"text"] dataUsingEncoding:NSUTF8StringEncoding]
options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
documentAttributes: nil
error: &err];
글로벌 대기열에서 코드를 실행하면 충돌이 해결되지 않습니다. 그러나 performSelectorOnMainThread를 수행 할 때 전역 대기열을 제거하면 잘 작동하지만 여전히 셀 재사용이 느려지 게됩니다. –