RMP
RMP

Reputation: 5391

How to reload a UIWebView as seamlessly as possible

I'm using a UIWebView to render local html content (special html content with javascript). The html content needs to get incrementally updated often, but every time that happens and I reload the web view, it does a little "dance" to refresh, which is very distracting, especially since the updates are very minor and happen often. If I could just freeze the display, reload the page behind the scenes, and then repaint the display, I'm sure that would look fine. But, can I do that? Or are there any other approaches to refresh an html page (or just some of the content of the page) seamlessly?

Thank you in advance for the help!

Upvotes: 0

Views: 808

Answers (1)

Guillaume Algis
Guillaume Algis

Reputation: 11016

You could:

  1. take a "screenshot" of the UIWebView, (see How to capture current view screenshot and reuse in code? (iPhone SDK));
  2. display it in a UIImageView over the UIWebView;
  3. reload the UIWebView;
  4. when the UIWebView has finished reloading, remove the UIImageView from the view hierarchy.

I doubt there is a way to tell the UIWebView to "freeze" the display while reloading as the Webkit rendering provides a feedback to the user about the page loading state.

Another solution would be to update the DOM with javascript (and XHR presumably), removing the need to reload the whole page in the UIWebView.

Upvotes: 1

Related Questions