Clear UIWebView content upon dismissal of modal view (iPhone OS 3.0)

Posted by Ricky on Stack Overflow See other posts from Stack Overflow or by Ricky
Published on 2010-05-29T00:51:18Z Indexed on 2010/05/29 0:52 UTC
Read the original article Hit count: 599

I currently have a UIWebView that is displayed within a modal view. It is basically a detail view that provides a view of a page when the user clicks a link. When the view is dismissed and then brought up again (when the user clicks another link), the previously-loaded content is still visible and the new content loads "on top" of the last content. This makes sense because the instance of the UIWebView persists between sessions and is only released when the memory is needed.

However, I would like to completely clear the UIWebView when the modal view is dismissed so that 1) content is cleared and 2) memory is freed. Thus far my research and attempts have not found an answer. These links haven't worked for me:

  1. http://stackoverflow.com/questions/2184688/is-it-possible-to-free-memory-of-uiwebview
  2. http://stackoverflow.com/questions/2311564/reused-uiwebview-showing-previous-loaded-content-for-a-brief-second-on-iphone

I've tried [[NSURLCache sharedURLCache] removeAllCachedResponses]; and setting the webView to nil and manually releasing the webView upon modal-view-dismiss to no avail. Any thoughts from the wizened masses?

© Stack Overflow or respective owner

Related posts about memory

Related posts about iphone-sdk-3.0