I've been trying to create a UIStoryboardSegue that mimics the "Cover Vertical" modal segue, but makes the view "Uncover," so that the segues look natural together. Here's my UIStoryboardSegue child class:
//RetreatVertical.m
#import "RetreatVertical.h"
@implementation RetreatVertical
-(void)perform {
UIView *oldView = [self.sourceViewController view];
UIView *newView = [self.destinationViewController view];
[oldView.window insertSubview:newView belowSubview:oldView];
[UIView animateWithDuration:0.3 animations:^{
oldView.center = CGPointMake(oldView.center.x, oldView.center.y + oldView.frame.size.height); }
completion:^(BOOL finished){ [oldView removeFromSuperview]; }
];
}
@end
When the user taps a button, a UIViewController slides into focus using the modal segue "Cover Vertical." When the user taps a button on the new UIViewController, that UIViewController slides back down, revealing the old UIViewController (using my custom segue "RetreatVertical"). That all works fine, however, whenever I tap any other button or interface element after both animations are completed, the app crashes with "EXC_BAD_ACCESS." I have no idea why, and the past hour of searching hasn't come up with anything.
Thanks!
EDIT: Why doesn't this strategy work?
- (void) perform {
UIView *sourceView = [self.sourceViewController view];
UIView *destView = [self.destinationViewController view];
[[self.sourceViewController superview] insertSubview:destView belowSubview:sourceView];
[UIView animateWithDuration:0.3 animations:^{
sourceView.center = CGPointMake(sourceView.center.x, sourceView.center.y + sourceView.frame.size.height); }
completion:^(BOOL finished){ [sourceView removeFromSuperview]; }
];
}