开发者

Strange flickering with UIWebView

I have this strange (short) flickering when pushing a new viewController which contains a UIView > UIWebView.

Inside the controller.m, which contains the UIWebView, I have this code setup for the webView:


//EXAMPLE 1

NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path];

NSString htmlData = [NSString stringWithFormat:@"<html><head><style type=\"text/css\"> { margin:0; padding:0; }body { background开发者_高级运维-color:#c6c6c6; width: 320px; font-family: Helvetica; font-size:13px; line-height: 18px; color:#404a52; } #someOtherStyles...</style></head><body><div id=\"mededelingenDetailViewHeader\"><h1>%@</h1><p class=\"date\">%@</p><p class=\"author\">%@</p></div><div id=\"mededelingenDetailViewContent\"><p>%@</p></div><!-- mededelingenContent --></body></html>", titleString, dateString, authorString, filteredDescription ];

[webView loadHTMLString:htmlData baseURL:baseURL];

With this code the flickering shows up when pushing this controller onto the window. But if I change the htmlData to something simpler like the code below without for e.g. css the flickering suddenly dissappears.


//EXAMPLE 2

NSString *htmlData = [NSString stringWithFormat:@"<html><head></head><body><h1>Some Header!</h1><p>Some text</p></body></html>"];

So is there a way to load an .html file inside my NSBundle and assign NSString to some HTML contents like I did with htmlData in example 1? Or is there any better way to do this?

Thx!


Is [webView loadHTMLString:htmlData baseURL:baseURL]; called from viewDidAppear? If so, that would explain the flicker: it's loading the HTML while the user watches. Move that call to viewDidLoad and see if that solves it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜