I'm trying to display a .rft file which is download for my server.
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.
Anyways searching here I found out that UITextV开发者_如何学Pythoniew can not display rtf text properly.
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.
Is there something I am missing ?
I populate the UIWebView here
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *RadioGuideString = [[NSString alloc] initWithData:responseData
encoding:NSUTF8StringEncoding];
[webview loadHTMLString:guideString baseURL:nil];
}
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?
Many Thanks -Code
Can you try this?
NSURL *url = <create NSURL object pointing to your file>;
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
If you have added the .rtf into the application then try this
NSString *filePath = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"<filename.extenssion>"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:fileURL];
[webView loadRequest:requestObj];
精彩评论