How to check which Tab Bar item is active?
I am tr开发者_JAVA百科ying to figure out how to check which tab bar button is active? Currently I have 5 to 6 different tab bar buttons, and want to check which one is active. Any input will be appreciated here.
Thanks,
Shawn
do you have UITabbar or UITabbarController?
if UITabbar
then set tag for each item and then you see which item is selected using -
tabBarController.tabBar.selectedItem.tag
if UITabbarController
then use
tabBarController.selectedIndex
UITabBarController has a selectedViewController and a selectedIndex property. Here is the UITabBarController documentation
精彩评论