开发者

RTF equivalent to UIWebView's loadHTMLString?

开发者 https://www.devze.com 2023-04-02 01:16 出处:网络
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.

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 l开发者_如何学编程ike 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号