【问题标题】:How to add transition for switching between tabbar viewcontrollers如何为标签栏视图控制器之间的切换添加过渡
【发布时间】:2012-10-09 12:09:16
【问题描述】:
我在我的应用中添加了UITabBarViewController,并添加了五个ViewControllers。每个VC 到TabBarItems 之一。所有这一切都运作良好。但是第三个view 是供用户输入一些数据的,所以我希望它显示为临时VC。临时VC 的通常转换是交叉溶解。这会使VC 从底部向上。
所以我的问题是如何制作此动画以在 TabBarItems 之间进行转换。
【问题讨论】:
标签:
iphone
ios
uitabbarcontroller
uitabbar
transition
【解决方案1】:
我使用这个函数来获取目标视图的索引。我会将此函数添加为父视图控制器的一部分,以供子视图控制器调用。这取决于你。
-(void) animateTabBarTransition:(NSInteger) destinationTabIdx{
UIView * fromView = self.tabBarController.selectedViewController.view;
UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:destinationTabIdx] view];
[UIView transitionFromView:fromView toView:toView duration:0.8
options:(destinationTabIdx > self.tabBarController.selectedIndex ? UIViewAnimationOptionTransitionFlipFromLeft: UIViewAnimationOptionTransitionFlipFromRight)
completion:^(BOOL finished) {
if (finished) {
self.tabBarController.selectedIndex = destinationTabIdx;
}
}];
}