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;