Is there an efficient way to load large amounts of text in a UITextView?

UITextView makes my application slow down because it contains a lot of text. I was wondering if there is some kind of third-party library that can load more text efficiently? I use attributedText to store all the text. If there is a better way, let me know. Any advice or suggestions are welcome.

textView.attributedText = attributeStr; 
+7
ios objective-c uitextview
source share
2 answers

Really? It worked out well. Please check this as I executed my UITextView.HELP_STATIC_CONTENT there is a constant variable that contains static texts for the help screen, which contains many texts (about 500 lines).

 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; 
0
source share

If you want to change only part of the text, you can directly change it using the textStorage property, for example:

 [textView.textStorage addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:range]; 
0
source share

All Articles