0

I read rtf file with code:

NSURL *rtfString = [[NSBundle mainBundle]URLForResource:@"Privacy Policy Imaspanse" withExtension:@"rtf"];
NSError *error;
NSMutableAttributedString *stringWithRTFAttributes = [[NSMutableAttributedString alloc]initWithFileURL:rtfString options:@{NSDocumentTypeDocumentAttribute : NSRTFTextDocumentType} documentAttributes:nil error:&error];
if (error) {
    NSLog(@"Error: %@", error.debugDescription);
} else {
    self.textLabel.attributedText = stringWithRTFAttributes;
}
self.scrollView.contentSize = [stringWithRTFAttributes size];

Problem is that long line do not wraps to the next line. How can I achieve it? I need text that will be screen width and max height

1 Answers1

1

try this way

self.textLabel.attributedText = stringWithRTFAttributes;
[self.textLabel setNumberOfLines:0];
[self.textLabel sizeToFit];
[self.textLabel setLineBreakMode:NSLineBreakByWordWrapping];
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39