iphone how to remove modal uiviewcontroller from memory

Posted by Scott Pendleton on Stack Overflow See other posts from Stack Overflow or by Scott Pendleton
Published on 2010-04-05T04:49:44Z Indexed on 2010/04/05 4:53 UTC
Read the original article Hit count: 662

Filed under:
|
|

I have a root UIViewController which has a property called webView. WebView is a UIViewController with a XIB that contains a UIWebView. From my root view I modally (is there any other way?) load the webView ViewController and set its URL, always to the same page.

I discovered that if, after loading the webView, I used its default Web page to navigate to another Web page, and then closed the webView and returned to the root controller -- AND THEN reopened the webView, that the webView was not showing the default page but rather the page I navigated to, which means the webView ViewController never got destroyed and removed from memory. This strikes me as very bad.

So in the root ViewController, I added this code under viewWillAppear:animated --

if (self.webView != nil) {
    self.webView = nil)
}

Is that sufficient? Is there a better way?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiviewcontroller