Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 自定义segue和导航控制器动画故障_Ios_Objective C_Uinavigationcontroller_Uinavigationbar_Segue - Fatal编程技术网

Ios 自定义segue和导航控制器动画故障

Ios 自定义segue和导航控制器动画故障,ios,objective-c,uinavigationcontroller,uinavigationbar,segue,Ios,Objective C,Uinavigationcontroller,Uinavigationbar,Segue,我使用定制的segue,它看起来像是使用导航控制器放大。当segue完成并调用方法pushViewController:animated:时,会出现故障效果。导航栏立即出现,并将scrollView的内容及其高度值(88像素)放在下面。下面的动画清楚地显示了效果: 如您所见,scrollView的内容在segue的最后阶段移动得非常快。 以下是segue的代码: - (void)perform { UIViewController *sourceViewController = se

我使用定制的segue,它看起来像是使用导航控制器放大。当segue完成并调用方法
pushViewController:animated:
时,会出现故障效果。导航栏立即出现,并将scrollView的内容及其高度值(88像素)放在下面。下面的动画清楚地显示了效果:

如您所见,scrollView的内容在segue的最后阶段移动得非常快。

以下是segue的代码:

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

    // Add the destination view as a subview, temporarily
    [sourceViewController.view addSubview:destinationViewController.view];

    // Transformation start scale
    destinationViewController.view.transform = CGAffineTransformMakeScale(0.05, 0.05);

    // Store original centre point of the destination view
    CGPoint originalCenter = destinationViewController.view.center;
    // Set center to start point of the button
    destinationViewController.view.center = self.originatingPoint;

    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{


                         destinationViewController.view.transform = CGAffineTransformMakeScale(1.0, 1.0);
                         destinationViewController.view.center = originalCenter;
                     }
                     completion:^(BOOL finished){

                         [destinationViewController.view removeFromSuperview];
                         [sourceViewController.navigationController pushViewController:destinationViewController animated:NO];

                     }];
}

我认为,问题是,通常(如果是推式segue)ViewController会将内容放低一点(导航栏的高度),并在segue期间这样做。但现在,它将segue视为自定义,并忽略导航栏(但显示它),并显示部分内容被导航栏重叠。当导航控制器显示新VC时,它会计算导航栏的高度,并立即将内容放下。我想,在这个过程中,可能有办法设置scrollView的属性,如内容大小和起始点,但我不知道如何实现这一点。

我现在没有XCode,所以我猜是这样的

那么,首先你做到了

// Add the destination view as a subview, temporarily
[sourceViewController.view addSubview:destinationViewController.view];
然后,你打电话来了

animateWithDuration:delay:options:animations:completion:
这就是你看到的动画。如果我是对的,这将导致整个视图覆盖导航视图,因为您将此视图添加到顶部

完成后,此视图将从superview中删除,但随后将其推入导航视图控制器。此步骤将导致在动画中看到的跳跃


这就是跳转发生的原因:覆盖整个视图的视图被删除(突然消失)。这将使导航视图再次出现(导航栏显示),然后将视图推入导航视图控制器,并立即将其嵌入导航视图中。这就是为什么它看起来像一个动画小故障,移动速度非常快

几乎是正确的,事实上,原因很清楚:这个小故障是由于在动画中显示VC而没有为NavBar添加填充,然后添加这个填充。但是我问了一些如何解决这个问题的想法。我能想到的一件事是,你可以把一个新的空视图推到导航视图堆栈中。然后,这个新视图可以添加destinationView作为其子视图并设置动画。我在iOS 7及更高版本中已经解决了这个问题,只需在故事板中添加透明(alpha=0)导航栏。将添加有问题的解决方案本身。iOS 6的问题仍然悬而未决,因为添加透明导航栏没有任何帮助。@RichardTopchiy您能详细介绍一下您的解决方案吗?如果基本上可以创建一个自定义的推送转换替代方案,在推送转换中,导航栏可以从一个VC平滑地过渡到另一个VC,而不必调整新视图的大小,那就太好了。@Nuthinking,视图控制器转换是一种方法。我现在不会使用有问题的代码。以下是有关自定义转换的链接: