使用“pushViewController”在 UITabController 中的选项卡之间切换时的动画
我在尝试使 UITabBarViewController 执行与 UINavigationController 执行 PushViewController 时相同的动画时遇到问题。
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
UIModalTransitionStyle transition = UIModalTransitionStyleFlipHorizontal;
[UIView setAnimationTransition:transition forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}
下面的代码在切换选项卡时执行动画:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}
如何修改上面的代码以执行从右侧滑动的动画,类似于将 viewController 推入导航控制器?
I am having trouble trying to make the UITabBarViewController perform the same animation that UINavigationController has when it performs pushViewController.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
UIModalTransitionStyle transition = UIModalTransitionStyleFlipHorizontal;
[UIView setAnimationTransition:transition forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}
The following code performs an animation when switching tabs:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}
How can I modify the code above to perform the slide from the right animation similar to pushing a a viewController into the navigation controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个链接: http ://haveacafe.wordpress.com/2009/04/06/animated-transition- Between-tabbars-view-on-iphone/
这个想法是,你需要使用选项卡bar 控制器的委托方法并使用特定的动画类 CATransition (因为您在视图之间“转换”)。查看 CATransition 文档,了解动画的类型/子类型。您可能需要一种带有 left 或 right 子类型的推送类型。
Take a look at this link: http://haveacafe.wordpress.com/2009/04/06/animated-transition-between-tabbars-view-on-iphone/
The idea is, you need to use the tab bar controller's delegate method and use the specific animation class CATransition (since you are 'transitioning' between views). Take a look at the CATransition documentation for the types / subtypes for the animation. You'll probably want a type of push with a subtype of left or right.