2

我在尝试使 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;}

如何修改上面的代码以从右侧动画执行幻灯片,类似于将 aa viewController 推入导航控制器?

4

1 回答 1

1

看看这个链接:http ://haveacafe.wordpress.com/2009/04/06/animated-transition-between-tabbars-view-on-iphone/

这个想法是,您需要使用选项卡栏控制器的委托方法并使用特定的动画类 CATransition(因为您正在视图之间“转换”)。查看动画类型/子类型的CATransition 文档。您可能需要一种带有 left 或 right 子类型的 push。

于 2011-04-19T15:02:32.373 回答