Removing fixed text width from an RTF file loaded into UITextView

微笑、不失礼 提交于 2019-12-12 04:37:44

问题


In my app I load the contents of an RTF file into a UITextView using this code:

NSURL *url = [[NSBundle mainBundle] URLForResource:[fileName stringByDeletingPathExtension] withExtension:[fileName pathExtension]];
NSError *error;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithFileURL:url 
                                                                           options:@{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}  
                                                                           documentAttributes:nil  
                                                                           error:&error];

[textView setAttributedText:attributedString];

The problem I am having is that the width of the UITextView is greater than the text with of the rtf file. I want the text to fill the whole with of my UITextView. You can see the problem below in the screenshot.

Is there a way to make this this happen? Thanks a lot!

来源:https://stackoverflow.com/questions/24970701/removing-fixed-text-width-from-an-rtf-file-loaded-into-uitextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!