Similar to this question, I built a custom segue that displayed the destination view pushing down the source view from the top. Now I am attempting to build an unwind segue that accomplishes the same animation, but in reverse. Any idea how I would go about this?
Asked
Active
Viewed 1,356 times
1 Answers
0
You can use the same custom segue class by performing the following check:
// check if the sourceViewController has been presented modally with a navigationController or just by itself.
UIViewController*presentingViewController = nil;
if ([sourceViewController.presentingViewController isKindOfClass:[UINavigationController class]]) {
presentingViewController = sourceViewController.presentingViewController;
}
else {
presentingViewController = sourceViewController;
}
// check which animation we need to perform
if ([destinationViewController.presentingViewController isEqual:presentingViewController]) {
// animation for unwind segue
...
}
else {
// animation for presenting segue
...
}

Gianluca Tranchedone
- 3,598
- 1
- 18
- 33
-
What goes in the //animation for unwind segue? A UIStoryboardSegue instance? – jdog Jun 16 '13 at 21:18
-
It goes in the -perform method of your UIStoryboardSegue subclass. For more info about it, check developer.apple.com/library/ios/documentation/uikit/reference/UIStoryboardSegue_Class/Reference/Reference.html. Your animation logic goes where I put the dots. – Gianluca Tranchedone Jun 16 '13 at 23:52
-
How do you handle the unwind segue animation logic, seeing as you obviously can't add the destination view as a subview of the source view? – agg23 Jun 17 '13 at 18:57
-
You can animate the two views any way you want. When you're done you can call `[sourceViewController presentViewController:destinationViewController animated:NO]` and you're done. – Gianluca Tranchedone Jun 20 '13 at 13:38