我使用自定义 segue,它看起来像带有导航 Controller 的放大。当 segue 完成并调用方法 pushViewController: animated:
时,会出现故障效果。导航栏立即出现,并将 scrollView 的内容放在下方,其高度值为(88 像素)。下面的动画清楚地展示了效果:
http://s7.postimg.org/7in5s980r/image.gif
如您所见,在 segue 的最后阶段,scrollView 的内容移动非常快。
这里是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];
}];
}
我认为,问题是通常(如果它是推送转场)ViewController 将内容放低一点(对于导航栏的高度)并在转场期间执行此操作。但是现在,它将 segue 视为自定义并忽略导航栏(但显示它)并显示部分内容被导航栏重叠。当 Navigation Controller 呈现新的 VC 时,它会计算 NavBar 的高度并立即放下内容。我认为,可能有办法在 segue 期间设置 scrollView 的属性,例如内容大小和起始点,但不知道如何实现。
最佳答案
我现在没有 XCode,所以这是我的猜测。
所以,首先你做了
// Add the destination view as a subview, temporarily
[sourceViewController.view addSubview:destinationViewController.view];
然后,你打电话
animateWithDuration:delay:options:animations:completion:
这是你看到的动画。如果我是对的,这会导致整个 View 覆盖导航 View ,因为您将此 View 添加到顶部。
完成后,此 View 将从 super View 中删除,但随后您将其推送到导航 View Controller 中。此步骤会导致您在动画中看到的跳跃。
这就是跳转发生的原因:覆盖整个 View 的 View 被删除(突然消失)。这让导航 View 再次出现(导航栏显示),然后 View 被插入导航 View Controller ,并且现在嵌入到导航 View 中。这就是为什么它看起来像一个动画故障并且移动得非常快。
关于ios - 自定义转场和导航 Controller 动画故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24836787/