UITextView导致我的App速度变慢,因为它包含大量文本.我想知道是否有某种第三方库可以有效加载更多文本?
我使用attributionText来保存所有文本.如果有更好的方法请告诉我.任何提示或建议表示赞赏.
我使用attributionText来保存所有文本.如果有更好的方法请告诉我.任何提示或建议表示赞赏.
textView.attributedText = attributeStr;
解决方法
真?它对我很好.请查看我如何实现我的UITextView.HELP_STATIC_CONTENT有一个常量变量,它包含我的帮助屏幕的静态文本,其中包含大量文本(大约500行).
UITextView *lblHelp = [[UITextView alloc]initWithFrame:CGRectMake(10,10,self.view.frame.size.width - 20,self.view.frame.size.height - 20)]; [lblHelp setBackgroundColor:[UIColor clearColor]]; [lblHelp setEditable:NO]; [lblHelp setSelectable:NO]; lblHelp.showsVerticalScrollIndicator=NO; lblHelp.showsHorizontalScrollIndicator=NO; [self.view addSubview:lblHelp]; NSString *string = HELP_STATIC_CONTENT; NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.alignment=NSTextAlignmentJustified; [paragraphStyle setLineSpacing:3]; [attrString beginEditing]; [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,string.length)]; [attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,string.length)]; [attrString endEditing]; lblHelp.attributedText = attrString;