iphone - 在 UITabController 中的选项卡之间切换时使用 'pushViewController' 动画

标签 iphone interface mobile 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 插入导航 Controller ?

最佳答案

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

这个想法是,您需要使用选项卡栏 Controller 的委托(delegate)方法并使用特定的动画类 CATransition (因为您是在 View 之间“转换”)。看看CATransition documentation对于动画的类型/子类型。您可能需要一种子类型为 left 或 right 的推送类型。

关于iphone - 在 UITabController 中的选项卡之间切换时使用 'pushViewController' 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5718315/

相关文章:

c# - 在接口(interface)中实现委托(delegate)

jquery - jQuery Mobile 中的页面转换后脚本不起作用

iphone - UIMenuController 没有出现

iphone - 从不同的 View Controller 访问来自 NSJSONSerialization 的数据

c# - 通过添加新接口(interface)而不是扩展现有接口(interface)来添加功能

java - 在 Android 应用发送的 HTTP 请求之间维护 cookie

css - 使用媒体查询从纵向切换到横向时出现问题

iphone - 无法调用 UIKeyboard 通知

ios - 当已选择 selectedIndex 时,返回代码中选项卡栏 Controller 的原始 View

sockets - 如何将一个套接字绑定(bind)到多个接口(interface)