iphone app - detect which tab bar item was pressed

后端 未结 7 1121
我寻月下人不归
我寻月下人不归 2020-12-10 02:16

i have a tab bar based application, with more than 5 tab bar items - so i get 4 of them directly showing in the view and the rest available by selecting the \"More\" tab. Wh

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 02:49

    You can detect when a tab has been pressed using the UITabBarDelegate methods: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UITabBarDelegate

    You can make your UITabBarController class be the delegate and add the method in the implementation:

    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item 
    { 
        NSLog(@"tab selected: %@", item.title); 
    } 
    

提交回复
热议问题