samedi 29 novembre 2014

Reverse a modal segue?

In my app, there's a login screen. On that login screen, there's also a register button. If a user clicks the register button, a modal segue is executed to present a register view.


However, when the user clicks 'cancel', I want to do the same animation but then in reverse. So basically the register view should slide down. I created a custom segue for this, but I don't know how to properly animate this. How can I do this?


ReverseModalSegue.m



#import "ReverseModalSegue.h"

@implementation ReverseModalSegue

- (void) perform {

UIViewController *src = (UIViewController *) self.sourceViewController;
[UIView transitionWithView:src.navigationController.view duration:0.5
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[src.navigationController popToViewController: [src.navigationController.viewControllers objectAtIndex:0] animated:NO];;
}
completion:NULL];
}

@end


ReverseModalSegue.h



#import <UIKit/UIKit.h>

@interface ReverseModalSegue : UIStoryboardSegue

@end



Aucun commentaire:

Enregistrer un commentaire