“Swipe back” is include as standard at navigationcontroller in iOS7.
How to code this function another version of iOS.
– (void)viewDidLoad
{
//Set gesture
UIPanGestureRecognizer *backViewGestureRecognizer
= [[UIPanGestureRecognizeralloc] initWithTarget:self
action:@selector(backViewGesture:)];
[self.view addGestureRecognizer:backViewGestureRecognizer];
}
– (void) backViewGesture:(UIPanGestureRecognizer *)sender
{
CGPoint translation = [sender translationInView:sender.view];
//Threshold : distance which how long move your thumb.
if (translation.x > 45.0) {
[self.navigationControllerpopViewControllerAnimated:YES];
[self.viewremoveGestureRecognizer:sender];
}
}
It’s easy way to code:)