Is it possible to preload content of a local file with embedded images for a UIWebView?
This is how I'm loading the data inside the UIWebView:
NSString *urlString = [[NSBundle mainBundle] pathForResource:@"info" ofType:@"html"];
NSString *htmlContent = [NSString stringWithContentsOfFile:urlString encoding:NSUTF8StringEncoding error:nil];
[myWebView loadHTMLString:htmlContent baseURL:nil];
But the UIWebView still needs some time to display the content. Is there any way to put this content into the browser cache on app start?
If you create the browser object on app start and load the HTML string immediately, it should work fine to display the view later.
Another option would be to allocate it when necessary, but not actually show the view until it's done loading (wait for
- (void)webViewDidFinishLoad:(UIWebView *)webView
to be called on the web view's delegate before showing it).Also, would it make more sense to call
than using the
loadHTMLString:
method? That way, you don't have to load the HTML string into memory yourself and the web view can load it directly from disk.