Posted By

yannxou on 12/07/10


Tagged

Objective-c iphone


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

suibhne
terababy


Detect back button touch on UINavigationController


 / Published in: iPhone
 

URL: http://www.comanswer.com/question/setting-action-for-back-button-in-navigation-controller

Code taken from comment by 'William Jockusch' in the URL.

  1. -(void) viewWillDisappear:(BOOL)animated {
  2. if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
  3. // back button was pressed. We know this is true because self is no longer
  4. // in the navigation stack.
  5. }
  6. [super viewWillDisappear:animated];
  7. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: the_coder on February 1, 2011

if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) should be written as if (![self.navigationController.viewControllers containsObject:self])

You need to login to post a comment.