Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good file type for displaying text and images in a UIWebView

A UIWebView can be used to display a variety of file types (ex: a.xls .key.zip .numbers.zip .pages.zip .pdf .ppt .doc .rtf .rtfd.zip .key .numbers and .pages).

I am working on a "How to use this application" part of my app and would like to find a good file type (stored locally) for displaying some text and images in a UIWebView.

The problem is lack of control over the final result. For example, text size seems to have no effect in either a .rtf or .doc file. I want to have a reasonable amount of control over the text and image properties. I could use a pdf, but I don't like the way the pdf's are framed, making everything that much smaller on the screen.

Does anyone have any experience displaying various file types in a UIWebView. What file type enables good creative control over the final result?

like image 543
Jonah Avatar asked Feb 26 '23 20:02

Jonah


1 Answers

I would use good old html. It has great support in UIWebview (duh), and is relatively easy to learn and create.

Update:

To display a local file, from a UIViewController, use a process like this

UIWebView *myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
[view loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"documentation" ofType:@"html"]]]];
while ([view isLoading]) {
    // wait...
}
[self.view.addSubview:myWebView];
[view release];

Or, for a remote file:

UIWebView *myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
[view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myserver.com/ios/documentation/documentation.html"]]];
while ([view isLoading]) {
    // wait...
}
[self.view.addSubview:myWebView];
[view release];
like image 99
Richard J. Ross III Avatar answered Mar 09 '23 00:03

Richard J. Ross III