0

我创建了两个自定义 segue 文件,并且在这两个文件中,我都覆盖了该perform方法。但是,似乎自定义 segue 仅在呈现 new 时才有效UIViewController,而相反的 segue 不设置动画,只是忽略了 source UIViewController

反向自定义segue:

- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
    UIViewController *sourceTabBarController = sourceViewController.parentViewController.parentViewController;
    UIViewController *destinationViewController = self.destinationViewController;
    UIGraphicsBeginImageContext(destinationViewController.view.bounds.size);
        [destinationViewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *destinationViewControllerImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

    UIImageView *destinationViewControllerImageView = [[UIImageView alloc] initWithImage:destinationViewControllerImage];
    destinationViewControllerImageView.userInteractionEnabled = YES;
    destinationViewControllerImageView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(destinationViewController.view.frame), CGRectGetHeight(destinationViewController.view.frame));

[destinationViewController.view insertSubview:destinationViewControllerImageView atIndex:1];

// Add animations
    [UIView animateWithDuration:0.4f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{
                         destinationViewControllerImageView.center = CGPointMake(-CGRectGetWidth(destinationViewControllerImageView.frame) / 2, -(CGRectGetHeight(destinationViewControllerImageView.frame) / 2));
                     }
                     completion:nil];

    [sourceViewController dismissViewControllerAnimated:NO completion:nil];
}

提前致谢!

4

1 回答 1

1

Segues 添加了一个新版本的视图控制器。刚开始时,我遇到了一些有趣的问题,即使用 segues 来关闭视图控制器。

而不是编写自定义 segue,您应该在“关闭”的视图控制器中使用自定义动画块。

于 2012-08-14T15:32:03.240 回答