rksprst
rksprst

Reputation: 6631

Run a method on tab switch or when leaving a UIViewController's focus

I'd like to run a method when a user switches to another tab or when the application is closed. Is there a way to do this with the iphone sdk?

I've tried looking at the methods for the view controllers and the tab bars, but I didn't see any methods that seemed to do this.

I've also tried doing this with "Editing Did End" methods, but that didn't seem to work.

Upvotes: 1

Views: 766

Answers (1)

Ben Gottlieb
Ben Gottlieb

Reputation: 85542

To run a method when a tab is tapped (and I'm assuming you're referring to a standard UITabBar), just implement tabBar:didSelectItem: in your tabBar's delegate.

To run code when your application quits, implement applicationWillTerminate: in your app's delegate.

Upvotes: 4

Related Questions