Iphone – Problem with viewing a text file on UIWebview

iphoneuiwebview

I have a problem when loading a text file with unicode content into a UIWebview.

How can I set Encoding for the UIWebview using loadRequest like this:

[myWebView loadRequest:[NSURLRequest
requestWithURL:[NSURL
fileURLWithPath:tempFilePath]]];

This code seem to work but I can't use it to open MS Office file:

[myWebView loadData:[NSData
dataWithContentsOfFile:tempFilePath]
MIMEType:self._mimetype
textEncodingName:@"UTF-8"
baseURL:nil];

Thanks for helping me.

Best Answer

What is the value of self._mimetype?

Based on this Technote, I do not believe you will be able to open .docx (zipped-XML) files, but you should be able to open .doc files.

Also make sure that you are using the correct MIME type in the latter case (application/msword).

Related Topic