我正在使用选项卡栏,即底栏,并有5个标签栏项目,我想为每个方法分配一个方法,以便我可以在选项卡栏上的其他视图导航到其他视图,请单击。<<<。/p>
我一直在寻找一些线索,但无法做到。
使用UITabBarDelegate
。
通过添加类定义
来实现您的课程并继承协议@interface MyViewController : UIViewController<UITabBarDelegate>
然后使用方法tabar:didSelectitem:在该类中
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
// Do Stuff!
// if(item.title == @"First") {...}
}
可能会帮助您
在swift
中实现Uitabardelegate并使用方法didSelect
class MyViewController: UIViewController, UITabBarDelegate {
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
}
}
还创建工具栏的IBOUTLET
toolbar.delegate = self