I found out that the replace segue and push segue were misleading because the replace seems to be available for a master detail controller and the push segue for a navigation controller only. In this case I needed to implement a customize segue instead. You need to subclass the UIStoryboardSegue and override the perform segue.
Here is an e.g of my code:
-(void)perform{
UIView *sourceView = [[self sourceViewController] view];
UIView *destinationView = [[self destinationViewController] view];
UIImageView *sourceImageView;
sourceImageView = [[UIImageView alloc]
initWithImage:[sourceView pw_imageSnapshot]];
// force the destination to be in landscape before screenshot
destinationView.frame = CGRectMake(0, 0, 1024, 748);
CGRect originalFrame = destinationView.frame;
CGRect offsetFrame = CGRectOffset(originalFrame, originalFrame.size.width, 0);
UIImageView *destinationImageView;
destinationImageView = [[UIImageView alloc]
initWithImage:[destinationView pw_imageSnapshot]];
destinationImageView.frame = offsetFrame;
[self.sourceViewController presentModalViewController:self.destinationViewController animated:NO];
[destinationView addSubview:sourceImageView];
[destinationView addSubview:destinationImageView];
void (^animations)(void) = ^ {
[destinationImageView setFrame:originalFrame];
};
void (^completion)(BOOL) = ^(BOOL finished) {
if (finished) {
[sourceImageView removeFromSuperview];
[destinationImageView removeFromSuperview];
}
};
[UIView animateWithDuration:kAnimationDuration delay:.0 options:UIViewAnimationOptionCurveEaseOut animations:animations completion:completion];
}
The main idea is to create a screenshot view of the source and destination scene; add them to the destination scene view, control the animation of those two views, call to the presentModalViewController function on the sourceviewController and remove the two screenshots views when done with the animation.
One can found an example of implementing a screenshot utility function here in Ch15 of this link: http://learnipadprogramming.com/source-code/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…