I have a simple navigation based app which has a bunch fo forms in it, I have a method connected to a button that saves data when the button is tapped but I was wondering if I could call the same method when the back button is tapped in the navigation? Just incase a user fails to use the save button. If it is possible, how would I go about it?
thanks in advance!
Your view controller’s
viewWillDisappear:method will be invoked when the back button is pressed (but also at other times), so that might be an option.However,
viewWillDisappear:will also be invoked if you present (say) a modalViewController, or push another viewController onto the navigation stack.The only method I can think of that will be invoked only when the controller is popped from the navigation stack is the
-deallocmethod.