![](/img/trans.png)
[英]How do I set selected tab in UITabBarController using StoryBoard?
[英]How can I programmatically set selected tab of UITabBarController while also triggering shouldSelectViewController in UITabBarControllerDelegate
我正在尝试为我的UITabBarController中的选项卡之间的过渡设置动画,当我按下选项卡按钮时,它可以正常工作。 但是,当我通过调用以编程方式切换选项卡时
[self.tabBarController setSelectedIndex:2];
在滑动手势识别器中,未在UITabBarControllerDelegate委托中调用shouldSelectViewController函数,因此不会触发我的动画。
有没有办法实现我想要的? 我是否可以通过编程方式以其他方式触发选项卡开关,以便调用shouldSelectViewController函数?
如果已在- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
的委托中实现- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
,则可以手动调用它。
[self.tabBarController.delegate tabBarController:self.tabBarController shouldSelectViewController:[[tabBar viewControllers] objectAtIndex:2]];
[self.tabBarController setSelectedIndex:2];
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.