2015-07-08 4 views
0

Я прочитал РТФ файл с кодом:IOS: Чтение RTF-файл с текстом оберточной

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]; 

Проблема заключается в том, что длинная линия не переносится на следующую строку. Как я могу это достичь? мне нужен текст, который будет ширина экрана и максимальная высота

ответ

1

попробовать этот способ

self.textLabel.attributedText = stringWithRTFAttributes; 
[self.textLabel setNumberOfLines:0]; 
[self.textLabel sizeToFit]; 
[self.textLabel setLineBreakMode:NSLineBreakByWordWrapping]; 
+0

не работает, то же самое –

+0

вы используете AutoLayout? @adsjfkasjdflkasjdflkdalfjsdlf –

Смежные вопросы