我有TabBarController
其中有3个viewcontrollers(即VCa,VCb,VCc),而在VCa,tabbar设置为隐藏。
现在每当我们在VCa上点击(使用UITapGestureRecognizer
)视图时,为了查看另一个ViewController(VCb或VCc),应该实现什么样的选择器方法。
“在viewdidLoad
VCa”
[self.tabBarController.tabBar setHidden:YES];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapmethod)];
[self.view addGestureRecognizer:tap];
-(void)tap{
// code to be written in order to show VCb(or any other ViewController in same TabBarController)
}
答案 0 :(得分:1)
将UITabBarViewController的selectedIndex设置为您想要显示的VC。
答案 1 :(得分:1)
简而言之:
- (void)tap {
self.tabBarController.selectedIndex = 1;
// or
self.tabBarController.selectedViewController = self.tabBarController.viewControllers[1];
}
将选择正确的标签栏项目。