使用的iOS 7的UIViewController过渡动画超过1 SEGUE放松 [英] Unwind with more than 1 segue using iOS 7 UIViewController transition animations

查看:203
本文介绍了使用的iOS 7的UIViewController过渡动画超过1 SEGUE放松的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用动画的UIViewController在iOS7引入过渡。我能产生一些真正伟大的过渡VC的使用塞格斯等之间来回

I am using the UIViewController animated transitions introduced in iOS7. I am able to produce some really great transitions going back and forth between VC's using segues etc.

下面我的照片看看:

我可以非常轻松地来回走,如果它是在同一时间只有一个SEGUE / ​​VC。例如,如果,我是从屏幕1到屏幕2,动画作品完美。然后说我回去1或转发到3,它完美的作品。

I can very easily go back and forth if it is just one segue/vc at a time. For example if, I go from Screen 1 to Screen 2, the animation works perfect. And then say I go back to 1 or forward to 3, it works perfectly.

但是,如果你在底部屏幕上的4注意到有一个按钮,上面写着回到屏幕1 - 这是一种平仓SEGUE屏幕1的问题是,我不能让过渡动画工作。事实上,委托方法永远不会被调用。

But, if you notice on screen 4 at the bottom there is a button that says "Back To Screen 1"—this is an unwinding segue to screen 1. The issue is, I can't get the transition animation to work. In fact, the delegate methods never get called.

下面是我有它设置(例如从动画屏幕2到3):

Here is how I have it set up (for example animating from screen 2 to 3):

//This is found in screen 2's view controller .m

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    if ([segue.identifier isEqualToString:@"screen2to3"]) {

        UIViewController *destination = segue.destinationViewController;
        destination.transitioningDelegate = self;
        destination.modalTransitionStyle = UIModalPresentationCustom;

    }
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {

    STSlideAnimation *animator = [STSlideAnimation new];
    animator.presenting = YES;
    return animator;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {

    STSlideAnimation *animator = [STSlideAnimation new];
    return animator;
}

//This is the unwinding segue action

-(IBAction)returnToScreen2:(UIStoryboardSegue *)segue{

}

这完美的作品会既SCREEN3和回画面2。动画被调用两种方式。但是,我不能让任何动画在时光倒流多个VC时工作。有任何想法吗?让我知道如果我需要发布更多的样品code。

This works perfect going both to screen3 and back to screen2. The animation gets called both ways. However, I can't get any animation to work when going back more than one vc at a time. Any ideas? Let me know if I need to post more sample code.

推荐答案

您需要的使自定义类赛格瑞为每种类型的过渡您想申请

#import <UIKit/UIKit.h>

@interface CustomSegue : UIStoryboardSegue

@end


@implementation CustomSegue

 -(void)perform {

 // write your transition code here
 // this code will be called every time transition is made

}

选择在storybord一个SEGUE - 在检查其类型更改为自定义 - 选择自定义类,你在上述情况下取得了CustomSegue结果


如果您有它的子类正确,那么你会发现督察如下




Select a segue in storybord - in inspector change its type to custom - select custom class you have made in above case "CustomSegue"

If you have subclassed it properly then you will find inspector as below

放松和往常一样,但会得到相同的效果,即使你已经从4控制器POP操作到第一控制器

Unwind as usual but will get the same effect even if you have poped from 4th controller to 1st controller

这篇关于使用的iOS 7的UIViewController过渡动画超过1 SEGUE放松的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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