-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (tabBarController.selectedIndex == 0) {
// present your first view controller
}
else if (tabBarController.selectedIndex == 1) {
// present your second view controller
}
else if (tabBarController.selectedIndex == 2) {
// present your third view controller
}
}
2 回答
在viewDidLoad中添加:为每个按钮分配视图控制器:
以下是检测按钮点击的方法:
使用UITabBarControllerDelegate可以获得有关选择了哪个选项卡的通知 .