【发布时间】:2014-07-19 04:36:23
【问题描述】:
我使用自定义 segue,看起来像使用导航控制器放大。当 segue 完成并调用方法 pushViewController: animated: 时,会出现故障效果。导航栏立即出现,并将滚动视图的内容与其高度(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 的属性,例如内容大小和起始点,但不知道如何实现。
【问题讨论】:
标签: ios objective-c uinavigationcontroller uinavigationbar segue