David K
David K

Reputation: 3243

iOS: Calling a method with tab bar item - possible?

In my app I have a tab bar at the bottom with 4 tab bar items, and what I want to do is run a method when a given tab bar item is pressed.

How can I do this?

The purpose of the methods is to send a javascript string/command to the same webview.

Upvotes: 0

Views: 1612

Answers (1)

lxt
lxt

Reputation: 31304

This is pretty straightforward: just use the UITabBarDelegate which lets you get callbacks whenever a tab bar item is selected.

See the Apple reference here:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarDelegate_Protocol/Reference/Reference.html

...and you want to look in particular at the tabBar:didSelectItem: method.

Upvotes: 3

Related Questions