iphone - 如何将UITabbar连接到ViewController

标签 iphone ios

我不使用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/

相关文章:

ios - 当您复制粘贴时,xib View 内的按钮/文本字段没有反应?

objective-c : alloc child class from parent and use parent class instance varriable

iphone - 在类之间传递NSString

ios - 如何在预览图层上设置正确的相机图像大小?

objective-c - 如何使用数组使按钮按特定顺序播放声音?

iphone - 合适的行单元格标题中的文本在 iOS 应用程序中渲染效果不佳

iphone - UIView的UIImagePickerController

iphone - iOS5 UIButton 我应该尝试优化背景图片吗?

iOS CoreData NSPredicate 未清除

iphone - 如何将带数字的字符串转换为逗号不是小数点的 NSDecimalNumber?