user698200
user698200

Reputation: 399

Which method is called when I return from navigation?

I want to do something when I push back button of navigation bar. In which method do I have to do that? viewDidUnload is not called. Do I have to do that in dealloc method?

Upvotes: 0

Views: 66

Answers (2)

Jonah
Jonah

Reputation: 17958

-viewWillDisappear: and -viewDidDisappear will be called on the currently visible view controller. -dealloc may or may not be called depending on if the navigation controller was the only object retaining that view controller and it is therefore not an appropriate place for such logic. If the controller is not deallocated -viewDidUnload may be called at some point in the future if the controller receives a memory warning.

On the previous view controller on the navigation stack -viewDidLoad may be called if that controller's view has been unloaded and needed to be reloaded. viewWillAppear: and viewDidAppear: will be called.

On the navigation controller's delegate -navigationController:willShowViewController:animated: and -navigationController:didShowViewController:animated: will be called.

Upvotes: 1

Manish Burman
Manish Burman

Reputation: 3079

The viewWillDisappear & viewDidDisappear methods are called :)

Upvotes: 1

Related Questions