Reputation: 8165
I use custom segue which looks like zoom-in with navigation controller. When segue finishes and method pushViewController: animated:
is being called, a glitch effect appears. Navigation bar appears immediately and puts contents of the scrollView below with the value of it's height (88 px). The animation below clearly represents effect:
http://s7.postimg.org/7in5s980r/image.gif
As you can see, content of the scrollView moves very fast at the final stage of segue.
Here is the code for 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];
}];
}
I think, the problem is that commonly (if it were a push segue) ViewController puts content down a bit (for a height of Navigation Bar) and does this during the segue. But now, it treats segue as custom and ignores Navigation Bar (but shows it) and shows part of the content being overlapped by NavBar. When Navigation Controller presents new VC, it does count for the height of NavBar and immediately puts content down. I think, there might be way to set scrollView's properties such as content size and originating point during the segue, but have no idea how to implement this.
Upvotes: 1
Views: 786
Reputation: 189
I don't have XCode now so here is my guess.
So, first you did
// Add the destination view as a subview, temporarily
[sourceViewController.view addSubview:destinationViewController.view];
Then, you called
animateWithDuration:delay:options:animations:completion:
Which is the animation you see. If I am right, this is cause the whole view to cover the navigation view since you add this view on top.
On completion this view is removed from superview, but then you pushed it into the navigation view controller. This step causes the jump you see in the animation.
This is why the jump happened: Your view which covered the whole view is removed (suddenly disappeared). This lets navigation view appears again (the navigation bar shows), then the view is push into navigation view controller, and it is embedded in the navigation view now. Thats why it looks like a animation glitch and moves really fast.
Upvotes: 1