我不使用UITabbarController,我只是在ViewController中添加UITabbar。我知道当我们使用UITabbarController时,我们将创建一个包含viewcontrollers的数组,因此,当我们点击选项卡时,将显示特定的viewcontroller,但是UITabbar可以添加UITabbarItems,那么如何将viewcontroller连接到Tab?就像UITabbarController一样。先感谢您。
最佳答案
将 UITabBarDelegate
附加到您的UITabBar
:
self.tabbar.delegate = self;
// make sure you declared self to be a UITabBarDelegate in your header
然后执行:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
// item is the selected tab bar item
}
关于iphone - 如何将UITabbar连接到ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9552089/