Provide a standard way to detect 'back' button in UINavigationController

Originator:raminf
Number:rdar://7001564 Date Originated:6/23/09
Status:Open Resolved:
Product:iPhone SDk Product Version:3.0
Classification:UI/Usability Reproducible:Always
 
Summary: 

Requesting a standard mechanism to capture when a user has tapped the 'back' button in a UINavigationController. Currently, the only way to do this is by overriding the viewWillDisappear method on the current view controller. However, that method is called when we're navigating forward, backward, or if a modal dialog is brought up over the current controller. 

Notification of the back button is needed in cases where the view controller has to perform some sort of clean-up work. 

It should be pointed out that there is currently support for {will|did}ShowViewController methods under UINavigationControllerDelegate but these are invoked only when a view is appearing. A corresponding {will|did}HideViewController methods with a flag indicating backward vs. forward would solve the problem.

Steps to Reproduce:

- Create a UINavigationController.
- Push a couple of view controllers onto the stack.
- Try to capture when the user has pressed the 'Back' button.
- In the second view controller, override viewWillDisappear, then observe that it gets called when going to third controller or when going back. If a modal dialog is popped in front, viewWillDisappear will also get called.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!