开发者

How can i get Tabbar Item Button's Click event by clicking on TabbarItem button?

I have taken UITabbar on that i have used two buttons as TabItem.I want to perform two different Action by clicking on that two button so h开发者_Go百科ow can i get particular Action on clicking on particular Tabbar button.


You most likely want to take advantage of the UITabBarControllerDelegate, and then handle the didSelectViewController method.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

See here for more details: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html


-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if(item.tag==1)
    {
        //your code
    }
    else
    {
       //your code
    }
}

You can use UITabBarDelegate for keeping the track of which button is pressed by assigning the tag or title for title you can use item.title.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜