Reputation: 215
I have a UINavigationController, and I was wondering how I can programmatically tell when it has been pressed?
I am asking because I need to perform some actions when the back button is pressed, and ONLY when the back button is pressed. There are cases when I programmatically press the back button, and I need to ignore those instances. Does anyone have a suggestion?
Thanks!
Here is how the problem was solved:
I have a flag set in my application delegate. Initially it is set to False. When I programmatically push the button I set it to TRUE. Then, in the viewWillAppear method of my top view controller, I test the flag and perform necessary actions. I then reset the flag to False.
Upvotes: 1
Views: 990
Reputation: 3758
There doesn't seem to be a delegate method for that, but there is this one which when used like this could work for what you need.
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if ([viewController isKindOfClass:[MasterViewController class]]) {
}
}
Upvotes: 0
Reputation: 5732
When you press the button programmatically set a flag. When you go to perform the post press actions check if the flag is set.
Upvotes: 3