RTF是否等于UIWebView的loadHTMLString? [英] RTF equivalent to UIWebView's loadHTMLString?
问题描述
自OS 3.0起,UIWebView支持 RTF文件./p>
如果您有.rtf文件,可以很容易地将其加载到uiwebview中,例如
NSString * path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];NSURL * url = [NSURL fileURLWithPath:path];NSURLRequest * request = [NSURLRequest requestWithURL:url];[webView loadRequest:request];
在加载存储在字符串变量中的HTML时,可以使用 loadHTMLString
.
如何将存储在字符串中的RTF直接加载到 UIWebView
中?例如,如果您的字符串包含 {\ rtf1 \ ansi \ ansicpg1252 \ cocoartf1038 \ cocoasubrtf360{\ fonttbl \ f0 \ fswiss \ fcharset0 Helvetica;} ...
,使用 loadHTMLString
可以按实际方式呈现它.
我希望能够从字符串变量中呈现RTF,而无需先将其保存到文件中.
尝试 loadData:MIMEType:textEncodingName:baseURL:
.还没有尝试过,但是值得一试.
Since OS 3.0 UIWebView supports RTF files.
If you have a .rtf file, it's easy enough to load it into a uiwebview, e.g.
NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
When loading HTML stored in a string variable, you can use loadHTMLString
.
How would one load RTF stored in a string directly into a UIWebView
? For example, if you have a string containing {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}.....
, using loadHTMLString
will render it literally.
I would like to be able to render RTF from a string variable without having first to save it to a file.
Try loadData:MIMEType:textEncodingName:baseURL:
. Haven't tried it, but it's worth a shot.
这篇关于RTF是否等于UIWebView的loadHTMLString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!