Code Code - 3 months ago 8x
iOS Question

Detecting when the 'back' button is pressed on a navbar

I need to perform some actions when the back button(return to previous screen, return to parent-view) button is pressed on a Navbar.

Is there some method I can implement to catch the event and fire off some actions to pause and save data before the screen disappears?


Just implement your own action for the button:

    [self.navigationItem.backBarButtonItem setAction:@selector(perform:)];

-(void) perform:(id)sender {

     //do your saving and such here

     [self.navigationController popViewControllerAnimated:NO];