Possible Duplicate:
Find out if user pressed the back button in uinavigationcontroller?
I want to play a sound when the user taps on the left-side button of a UINavigationController (the “back” button).
How can I detect this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Another simple way is to implement your sound in the viewWillDisappear():
Or a more robust method, to ensure the sound only plays when the back button is pressed (in the case you have other ways the view may be popped from the navigation stack) is to subclass the UINavigationController and put in a custom action method for your back button. This page gives you an example of how to do this.
The example basically subclasses UINavigationController and over-rides the
method which is called when the back button is pressed.