奇怪的segue z位置行为

时间:2014-06-18 21:52:08

标签: ios objective-c

我正在尝试创建一个自定义segue,它将destinationViewController放在sourceViewController下面,然后向左滑动sourceViewController以显示下面的destinationViewController。这似乎是一个非常简单的问题,但由于某种原因,我根本无法让它工作。以下是我的自定义segue的实现:

#import "ForwardSegue.h"
#import "QuartzCore/QuartzCore.h"

@implementation ForwardSegue

- (void)perform {

    UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
    UIView *destinationView = ((UIViewController *)self.destinationViewController).view;

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    destinationView.center = CGPointMake(sourceView.center.x, sourceView.center.y);
    [window insertSubview:destinationView belowSubview:sourceView];

    [UIView animateWithDuration:0.3
                     animations:^{
                         sourceView.center = CGPointMake(0-sourceView.center.x, sourceView.center.y);
                     }
                     completion:^(BOOL finished) {
                         [[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:nil];
                     }];

}

@end

执行此segue时,destinationViewController会立即显示在sourceViewController上方而没有动画。我哪里出错?

0 个答案:

没有答案