I am using the UIViewController animated transitions introduced in iOS7. I am able to produce some really great transitions going back and forth between VC's using segues etc.
Take a look at my picture below:
I can very easily go back and forth if it is just one segue/vc at a time. For example if, I go from Screen 1 to Screen 2, the animation works perfect. And then say I go back to 1 or forward to 3, it works perfectly.
But, if you notice on screen 4 at the bottom there is a button that says "Back To Screen 1"—this is an unwinding segue to screen 1. The issue is, I can't get the transition animation to work. In fact, the delegate methods never get called.
Here is how I have it set up (for example animating from screen 2 to 3):
//This is found in screen 2's view controller .m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"screen2to3"]) {
UIViewController *destination = segue.destinationViewController;
destination.transitioningDelegate = self;
destination.modalTransitionStyle = UIModalPresentationCustom;
}
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
STSlideAnimation *animator = [STSlideAnimation new];
animator.presenting = YES;
return animator;
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
STSlideAnimation *animator = [STSlideAnimation new];
return animator;
}
//This is the unwinding segue action
-(IBAction)returnToScreen2:(UIStoryboardSegue *)segue{
}
This works perfect going both to screen3 and back to screen2. The animation gets called both ways. However, I can't get any animation to work when going back more than one vc at a time. Any ideas? Let me know if I need to post more sample code.