views:

155

answers:

2

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.

+3  A: 

When you press the button programmatically set a flag. When you go to perform the post press actions check if the flag is set.

Gary
I already have the flag system in place. The problem is that I reset the flag every time the subview was unloaded. The result was that when the subview was up and then programmatically unloaded, it would set that flag to false no matter what -- it seems that the view unloads after all my code fires. But what you said made me think of things a bit differently -- I stopped setting the flag when the subview unloaded, and set it false elsewhere. Thank You!
IcyBlueRose
A: 
sciritai
Thanks for the suggestion!
IcyBlueRose