Iphone 如何获取选项卡栏项目按钮';单击TabbarItem按钮来单击事件?

Iphone 如何获取选项卡栏项目按钮';单击TabbarItem按钮来单击事件?,iphone,Iphone,我使用了uitabar,我使用了两个按钮作为TabItem。我想通过单击这两个按钮来执行两个不同的操作,因此如何在单击特定Tabbar按钮时获得特定操作 您很可能希望利用UITabBarControllerDelegate,然后处理didSelectViewController方法 - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)

我使用了uitabar,我使用了两个按钮作为TabItem。我想通过单击这两个按钮来执行两个不同的操作,因此如何在单击特定Tabbar按钮时获得特定操作

您很可能希望利用UITabBarControllerDelegate,然后处理didSelectViewController方法

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
有关更多详细信息,请参见此处:


通过为
title
分配
标签或
标题,您可以使用
uitabardelegate
跟踪按下哪个按钮,您可以使用
项。title

如果您不使用实际的TabBarController,只想在中捕获一些tab-bar点击事件,此解决方案很好普通视图控制器。谢谢
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if(item.tag==1)
    {
        //your code
    }
    else
    {
       //your code
    }
}