Cipramill's answer is correct - here are more details.
IOS documentation suggests adding new views to outline areas in which you want page gestures to become active, but this method is much simpler. Adding code to the default template installed by Xcode 4 in MQ1RootViewController.h and MQ1RootViewController.m:
Change the interface line in MQ1RootViewController.h:
@interface MQ1RootViewController : UIViewController <UIPageViewControllerDelegate, UIGestureRecognizerDelegate>
Add this code to the very bottom of the DidLoad window in MQ1RootViewController.m:
for (UIGestureRecognizer *gR in self.pageViewController.gestureRecognizers) { gR.delegate = self; }
Add this method to MQ1RootViewController.m:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] || [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { CGPoint point = [touch locationInView:self.view]; if(point.x < 100 || point.x > 924) return YES; } return NO; }
Note that the swipe gesture actually comes from the βpanβ gestures using the page view controller object.
The above restricts gestures at the left and right edges of the screen. This allows you to use gestures to interact with objects in the center of the screen, not accidentally changing the page with an erroneous hit.
source share