在UIWebView中显示.rtf文件 [英] Displaying a .rtf file in an UIWebView
问题描述
我正在尝试显示为我的服务器下载的.rft文件。
I'm trying to display a .rft file which is download for my server.
我首先使用的是UITextView,但是我可以看到文本但是有还显示了许多与颜色和格式相关的编码和奇怪的字符。
I first used a UITextView, but I could see the text but there was a lot of encoding and strange character relating to colors and formatting also been shown.
无论如何在这里搜索我发现UITextView无法正确显示rtf文本。
Anyways searching here I found out that UITextView can not display rtf text properly.
所以我继续尝试一个本应能够显示.rft文件的UIWebView,但是它的内容与大量的\pard \tx566 \ tx1133类型相同出现在整个文件中。
So I moved on to trying a UIWebView which was supposed to be able to display .rft files, but alas its the same with lots of \pard\tx566\tx1133 type stuff appearing through out the file.
我缺少什么?
我在这里填充UIWebView
I populate the UIWebView here
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *RadioGuideString = [[NSString alloc] initWithData:responseData
encoding:NSUTF8StringEncoding];
[webview loadHTMLString:guideString baseURL:nil];
}
设置UIWebView的代码
Code for setting up the UIWebView
webview = [[UIWebView alloc] initWithFrame:CGRectMake(5, 50, 310, 400)];
webview.autoresizesSubviews = YES;
[webview setBackgroundColor:[UIColor clearColor]];
[webview setOpaque:NO];
[[self view] addSubview:webview];
我错过了一个特殊命令吗?
Is there a special command I have missed?
非常感谢
-Code
Many Thanks -Code
推荐答案
你能试试吗?
NSURL *url = <create NSURL object pointing to your file>;
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
这篇关于在UIWebView中显示.rtf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!