There are a few question about this, which has a solution regarding the script embedded in html string. Not in my case.
I have a ios5/6 app.
I have tryed to put the loading code into initWithNibName bad idea, viewDidLoad is deprecated , so viewWillAppear left.
- (void) viewWillAppear:(BOOL)animated
{
NSString* detailHtml = [Storage getDetailHtml: -1];// get the last one
//NSLog(@"detailHtml: %@", detailHtml);
if(detailHtml == nil){
NSLog(@"Can't load the detail");
detailHtml = @"<html><body>Some text here</body></html>";
}
[webView loadHTMLString:detailHtml baseURL:nil];
[super viewWillAppear:animated];
}
The problem with this code is flashing. It appears the UIViewContoller, with a white webView than after 1-2 seconds it is displayed the html. The HTML has some texts, but has base64 encoded images too, sometimes it is around 3Mb even 5MB content. No javascript is here, just inline CSS ( no external file ), text and base 64 encoded images.
I could pre-load into detailHtml the text, but I think the displaying takes more time.
Is that possible to do not display the ViewController, until the webView hasn’t finished loading the html ? – some callback?
Any suggestions?
That would take little bit time to load the HTML string default.But if everything works fine the why don’t you put
UIActivityIndicatorso that would keep user engaged with the app.Even much better than keeping it blankHere is one the delegate method of
UIWebView: