Reputation: 75
i add a login view above on my app NavigationController,when login success,the login view hidden.and when press a logout button,the view will show.during logout,i wanna free the navicontroller's memory, the navicontroller has much view and data model,when logout it,wanna free all just leave the navi.
has any method to do it? thx.
Upvotes: 0
Views: 599
Reputation: 2531
You can use your UIViewController
's (doc) viewDidDisappear
and viewWillAppear
callbacks to get rid of or recreate some of your view and data. But memory management in iOS will surely do housekeeping for you and call your controllers viewDidUnload
method on low-memory conditions (memory warnings). So I suggest your implement your clean-up within the viewDidUnload
method and care for view and data setup in viewDidLoad
. See the comment of viewDidUnload
for more Info:
When a low-memory condition occurs and the current view controller’s views are not needed, the system may opt to remove those views from memory. This method is called after the view controller’s view has been released and is your chance to perform any final cleanup. If your view controller stores references to the view or its subviews, you should use this method to release those references (if you retained the objects initially) and set those references to nil. You can also use this method to release any objects that you created to support the view but that are no longer needed now that the view is gone. You should not use this method to release user data or any other information that cannot be easily recreated.
Upvotes: 1