I am currently using a modal segue in my storyboard to go from one view to another with a button. And on the way back I am using a button to run a custom segue with my ABCustomSegue. It is all working fine I just want to be able to run this custom segue after the user preforms a swipe. How might I achieve that?
ABCustomSegue:
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil];
}];
}
Current Swipe Recognizer:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIScreenEdgePanGestureRecognizer *bezelSwipeGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(swipeBack:)];
bezelSwipeGestureRecognizer.edges = UIRectEdgeTop;
bezelSwipeGestureRecognizer.delegate = self;
[self.view addGestureRecognizer:bezelSwipeGestureRecognizer];
UIView *invisibleScrollPreventer = [UIView new];
invisibleScrollPreventer.frame = CGRectMake(0, 0, self.view.frame.size.width, 30);
[self.view addSubview:invisibleScrollPreventer];
}
-(void)swipeBack:(UIScreenEdgePanGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateEnded) {
NSLog(@"swipe back");
}
}
Thank you!
Try this code:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];