跳转导航树后面的几个步骤,自定义动画 [英] Jump back several steps in navigation tree with custom animation

查看:88
本文介绍了跳转导航树后面的几个步骤,自定义动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跟进<一个问题href=\"http://stackoverflow.com/questions/11392567/how-to-go-back-to-$p$pvious-view-in-objective-c\">this 之一

说我的应用程序有几个 ViewControllers ,让我们称他们为A,B,C,D。通常由D移动退一万步,即 - > C,将使用在导航栏或通过code后退按钮与行

Say my app has several ViewControllers, let's call them A,B,C,D. Usually moving back one step, i.e. from D -> C, would be using the back button in the NavigationBar or via code with the line

[self.navigationController popViewControllerAnimated:YES];

我想要做的就是要后退了好几步,像由D是什么 - > B.这将与

[self.navigationController popToViewController:B animated:YES];

不幸的是这种方式,我不能决定使用哪个动画。取而代之的是默认的动画我必须使用翻转动画。

Unfortunately this way I can't decide which animation to use. Instead of the default animation I have to use a Flip animation.

要做到这一点我发现这种方法唯一的办法

The only way to do this I found was this method

[self.navigationController transitionFromViewController:self.navigationController.presentedViewController toViewController:B duration:300 options:UIViewAnimationOptionTransitionFlipFromRight animations:nil completion:nil]; 

这是实现这一目标的唯一途径或任何人都可以提出一个更好的办法做到这一点?

Is this the only way to achieve this or can anyone suggest a better way to do it?

推荐答案

从您的意见参考。

听起来是正确的,但我哪里会定义,它应该是一个翻转动画至于我可以看到这仍然使用默认的动画 - ?taymless

" sounds right, but where would I define that it's supposed to be a flip animation? As far as I can see this still uses the default animation. – taymless "

您需要执行动画意味着你使用code的此块....

you need to perform the animation means you use this block of code....

  -(void)animatefromView:(UIView*)fromView toBlock:(void (^)(void))block // note block may be any executable code...
    {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration: 1];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:fromView cache:NO];
        block();
        [UIView commitAnimations];

    }

和方法调用将....

and the method call will be....

[self animatefromView:self.navigationController.view toBlock:^{ 
        [self.navigationController pushViewController:ani animated:NO];
                                                                    }];

我希望这将帮助你...

i hope this will help you...

这篇关于跳转导航树后面的几个步骤,自定义动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆