-1

in my iPhone application I need to check that user has clicked back button in Navigation controller. I think that I should get this in following method:

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

}

I don't want to override back button event. How can I get information that use click back button and navigation stack has changed?

Update Is it possible to know that in viewDidAppear method?

revolutionkpi
  • 2,632
  • 10
  • 45
  • 84

1 Answers1

3

You can use the method described in this answer : Setting action for back button in navigation controller

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

Hope this helps, Vincent

Community
  • 1
  • 1
vdaubry
  • 11,369
  • 7
  • 54
  • 76