我有一个.rtf
文件。它包含带有Windows Metafile Format(wmf)
. 我想在iOS
应用程序中显示这个文件。我尝试使用NSAttributedString
and in显示它,UIWebView
但未显示图像。如何在iOS
设备上显示它?
编辑
对于NSAttributedString
:
var urlpath = NSBundle.mainBundle().pathForResource("txtFile", ofType: "rtf")
var url:NSURL = NSURL.fileURLWithPath(urlpath!)!
if let attributedText = NSAttributedString(fileURL: url, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil, error: nil) {
textView.attributedText = attributedText
}
对于UIWebView
:
NSString *path = [[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"rtf"];
NSURL *url = [NSURL URLWithString:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
编辑2
我尝试将.rtf
文件转换为.rtfd
文件格式。
TXT.rtf
RTFD 文件在文件中创建包含和图像的捆绑包。在TXT.rtf
文件中,图像作为参考给出,分别存储在 RTFD 中。如下所示:
{{\NeXTGraphic img1.png \width40 \height20}¬}
我将文件转换为 RTFD,但是当文件包含.wmf
图像时会出现问题。.wmf
文件格式的图像没有得到转换。