4

对于一个项目,我需要在 iPad 上显示 RTF 文件的内容。经过一番搜索,我发现您可以在 UIWebView 中加载 RTF 文件。但是,当我这样做时,会显示文件的内容,但缺少表格边框和图像。粗体/斜体/下划线文本工作正常。

我用来显示文件的代码:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"A" withExtension:@".rtf"];

NSLog(@"URL: %@", url);

NSURLRequest *req = [NSURLRequest requestWithURL:url];

[_webView loadRequest:req];

RTF 文件:

https://dl.dropbox.com/u/4966217/A.rtf

如何在我的应用程序中显示图像和表格边框?

4

2 回答 2

0

If you want only to show rtf file then you can also use QLPreviewController. It supports many file formats for preview.

Here is the documentation link for QLPreviewController: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/QLPreviewController_Class/Reference/Reference.html

And here is sample code : http://developer.apple.com/library/ios/#samplecode/DocInteraction/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010052

于 2012-12-05T07:21:45.530 回答
-2

试试这个代码

NSString *filePath = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"A.rtf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:fileURL];
[_webView loadRequest:requestObj];

将其转换为 html

http://dblog.com.au/iphone-development/loading-local-files-into-uiwebview/

http://kiefermat.com/2011/09/30/using-uiwebview-for-displaying-rich-text/

于 2012-10-05T07:12:19.567 回答