iOS 7 uinavigationcontroller how to detect swipe?
ios, ios7, iphone, uigesturerecognizer, uinavigationcontroller
Solution
The interactive pop gesture recognizer is exposed through `UINavigationController`'s `interactivePopGestureRecognizer` property. You can add your own controller as a target of the gesture recognizer and respond appropriately:
@implementation MyViewController
...
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController.interactivePopGestureRecognizer addTarget:self
action:@selector(handlePopGesture:)];
}
- (void)handlePopGesture:(UIGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan)
{
// respond to beginning of pop gesture
}
// handle other gesture states, if desired
}
...
@end
Problem
In the new iOS 7 `UINavigationController`, there is a swipe gesture to switch between views. Is there a way to detect or intercept the gesture?