Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 视图转换在自定义pop segue期间不设置动画_Ios_Uistoryboardsegue - Fatal编程技术网

Ios 视图转换在自定义pop segue期间不设置动画

Ios 视图转换在自定义pop segue期间不设置动画,ios,uistoryboardsegue,Ios,Uistoryboardsegue,当我将新的视图控制器推到导航堆栈上时,我正在使用自定义序列创建扩展动画。如果在调用prepareForSegue:sender:时未指定sourceRect,则目标视图控制器将从源视图控制器的中心展开 ExpandSegue.m: expand segue按预期工作。我试图通过反转扩展序列的逻辑来创建一个折叠序列,但这给了我一些问题。我希望源代码视图控制器缩小到destinationRect的大小。如果未提供destinationRect,则我希望视图收缩到目标视图控制器视图的中心 Collap

当我将新的视图控制器推到导航堆栈上时,我正在使用自定义序列创建扩展动画。如果在调用prepareForSegue:sender:时未指定sourceRect,则目标视图控制器将从源视图控制器的中心展开

ExpandSegue.m:

expand segue按预期工作。我试图通过反转扩展序列的逻辑来创建一个折叠序列,但这给了我一些问题。我希望源代码视图控制器缩小到destinationRect的大小。如果未提供destinationRect,则我希望视图收缩到目标视图控制器视图的中心

CollapseSegue.m:

sourceViewController的视图没有很好地设置动画,而是简单地消失,就好像我只调用了[sourceViewController.navigationController popViewControllerAnimated:NO];这似乎表明我没有正确设置视图层次结构,但我似乎无法找出哪里出了问题!任何帮助都将不胜感激

- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination {
    self = [super initWithIdentifier:identifier source:source destination:destination];

    self.sourceRect = CGRectMake(source.view.center.x, source.view.center.y, 0.0, 0.0);

    return self;
}

- (void)perform {
    UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
    UIViewController *destinationViewController = (UIViewController *)self.destinationViewController;

    CGRect destinationRect = sourceViewController.view.frame;
    CGFloat tx = self.sourceRect.origin.x + self.sourceRect.size.width/2 - destinationRect.origin.x - destinationRect.size.width/2;
    CGFloat ty = self.sourceRect.origin.y + self.sourceRect.size.height/2 - destinationRect.origin.y - destinationRect.size.height/2;
    CGFloat sx = self.sourceRect.size.width/destinationRect.size.width;
    CGFloat sy = self.sourceRect.size.height/destinationRect.size.height;

    [sourceViewController.view addSubview:destinationViewController.view];
    [destinationViewController.view setFrame:sourceViewController.view.frame];
    [destinationViewController.view setTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(sx, sy), CGAffineTransformMakeTranslation(tx, ty))];

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationCurveEaseOut
                     animations:^{
                         [destinationViewController.view setTransform:CGAffineTransformIdentity];
                     } completion:^(BOOL finished) {
                         [destinationViewController.view removeFromSuperview];
                         [sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
                     }];
}
- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination {
    self = [super initWithIdentifier:identifier source:source destination:destination];

    self.destinationRect = CGRectMake(source.view.center.x, source.view.center.y, 0.0, 0.0);

    return self;
}

- (void)perform {
    UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
    UIViewController *destinationViewController = (UIViewController *)self.destinationViewController;

    CGRect sourceRect = sourceViewController.view.frame;
    CGFloat tx = self.destinationRect.origin.x + self.destinationRect.size.width/2 - sourceRect.origin.x - sourceRect.size.width/2;
    CGFloat ty = self.destinationRect.origin.y + self.destinationRect.size.height/2 - sourceRect.origin.y - sourceRect.size.height/2;
    CGFloat sx = self.destinationRect.size.width/sourceRect.size.width;
    CGFloat sy = self.destinationRect.size.height/sourceRect.size.height;

    [sourceViewController.navigationController popViewControllerAnimated:NO];
    [destinationViewController.view addSubview:sourceViewController.view];
    [sourceViewController.view setFrame:destinationViewController.view.frame];

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationCurveEaseOut
                     animations:^{
                         [sourceViewController.view setTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(sx, sy), CGAffineTransformMakeTranslation(tx, ty))];
                     } completion:^(BOOL finished) {
                         [sourceViewController.view removeFromSuperview];
                     }];
}