Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force a UIWebView to update when it's offscreen?

Tags:

iphone

I have a UIWebView that I'm setting to some text and displaying and then hiding, changing the text, and displaying again. The issue I'm running in to is that when I make the view visible again I see the old text for an instant. Is there a way to force the UIWebView to show the new text when it displays?

The code is ordered correctly and looks like this:

[back assignLabelText:[facts getCurrentFact].answer];
[self doAnimation:back.view andViewToHide:front.view flipRight:YES];
like image 543
Scotch Avatar asked Oct 15 '22 00:10

Scotch


2 Answers

You should wait until at least the webview's webViewDidFinishLoad: is fired before revealing the webview. Even then there can be some lag, so I add an additional 0.1 second delay before revealing the view.

like image 106
Brian Avatar answered Oct 21 '22 04:10

Brian


Call setNeedsDisplay on back's view

[back assignLabelText:[facts getCurrentFact].answer];
[[back view] setNeedsDisplay];
[self doAnimation:back.view andViewToHide:front.view flipRight:YES];
like image 27
falconcreek Avatar answered Oct 21 '22 06:10

falconcreek