Is it possible to load local html files with this? #5

Closed
BrianGilbert opened this Issue Jun 7, 2012 · 2 comments

Projects

None yet

3 participants

@BrianGilbert

I've been trying to figure out a way, but had no luck so far.

@tonisalae
Owner

You can't do it with the current version of TSMiniWebBrowser. To load local html files you should modify or subclass TSMiniWebBrowser and initialize the internal UIWebView like this:

NSString *imagePath = [[NSBundle mainBundle] resourcePath];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

NSString *fileString = [[NSBundle mainBundle] pathForResource:"your_html_file_name" ofType: @"html"];
NSString *newHTMLString = [[NSString alloc] initWithContentsOfFile: fileString encoding: NSUTF8StringEncoding error: NULL];
[webView loadHTMLString:newHTMLString baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]];

HTH

@alexcoplan
Contributor

@BrianGilbert it doesn't really make much sense to use this for local stuff. Most of it is designed for browsing remotely; reloading, open in safari, activity indicator etc... it'll probably be easier for you to just use a plain old UIWebView wrapped in whatever you want.

@tonisalae tonisalae closed this Sep 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment