Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RTF中的NSAttributedString仅适用于iOS 8,不适用于iOS 7_Ios_Uitextview_Rtf_Nsattributedstring - Fatal编程技术网

RTF中的NSAttributedString仅适用于iOS 8,不适用于iOS 7

RTF中的NSAttributedString仅适用于iOS 8,不适用于iOS 7,ios,uitextview,rtf,nsattributedstring,Ios,Uitextview,Rtf,Nsattributedstring,我正在尝试使用以下代码在UITextView中加载RTF文件: NSURL * filePath = [[NSBundle mainBundle] URLForResource:_fileName withExtension:@"rtf"]; NSAttributedString *stringWithRTFAttributes = [[NSAttributedString alloc] initWithFileURL:filePath options:@{NSDocumentTypeDocu

我正在尝试使用以下代码在UITextView中加载RTF文件:

NSURL * filePath = [[NSBundle mainBundle] URLForResource:_fileName withExtension:@"rtf"];

NSAttributedString *stringWithRTFAttributes = [[NSAttributedString alloc] initWithFileURL:filePath options:@{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType} documentAttributes:nil error:nil];
myTextView.attributedText = stringWithRTFAttributes;

在iOS 8上它工作得很好,但在iOS 7上它不工作,它只显示没有属性的文本。

我解决了这个问题,将RTF文件保存为HTML(使用TextEdit),并将代码更改为

NSURL * filePath = [[NSBundle mainBundle] URLForResource:_fileName withExtension:@"html"];

NSAttributedString *stringWithHTMLAttributes = [[NSAttributedString alloc] initWithFileURL:filePath options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
myTextView.attributedText = stringWithHTMLAttributes;

有人能帮我吗?它和iOS8.0一起工作吗?我得到了“libc++abi.dylib:以std::out_of_range:vector类型的未捕获异常终止”,而它确实适用于以后的8.x版本!不幸的是,我没有iOS 8.0设备,但部署目标设置为7.0。我想,这是一个运行时错误?也许有人有iOS 8.0设备,可以测试它??