Affecting a UINavigationBar's Back Button Method (iOS)

I have a table view that pushes to a detail view controller. From the detail view controller, when I press the 'back' button, I'd like an integer value to change. How do I edit the navigation bar back button's action programatically. The back button is automatically placed in my app because I'm using a table view so I didn't actually create the button, so I don't know how to affect it's method.

To be clear, I still want the back button to go back to the original view, but simultaneously change an integer's value. Thanks!

Answers


Thanks PengOne to point me to this direction. Add the UINavigationBarDelegate in the header file and use this in the .m file:

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem     *)item
{
  //insert your back button handling logic here
  // let the pop happen
  return YES;
}     

Need Your Help

How should I store trivial data in a database?

php mysql database-design web-applications metadata

I have a web application which allows people to upload flipbook animations. There are always a lot of requests for new features such as:

Looking for advice on WCF Fault Contracts

wcf design exception faultcontract

I have a situation where I want to be able to distinguish between different types of errors within a web service. In an API this would usaully be a separate exception for each, does this mean I sho...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.