2012-05-15 203 views

回答

1

一旦識別出你應該能夠檢索locationInView,然後如果這是一個可接受的值進行手勢,否則不是。

0

首先添加類接口。

@interface MyPageViewController :UIViewController<UIPageViewControllerDelegate, UIGestureRecognizerDelegate> 

然後在viewDidLoad中添加

for (UIGestureRecognizer *recognizer in self.pageViewController.gestureRecognizers) { 

     recognizer.delegate = self; 

} 

然後實現shouldReceiveTouch方法

#pragma mark - UIGestureRecognizer delegate methods 
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ 


    CGPoint touchPoint = [touch locationInView:self.pageViewController.view]; 

    CGRect innerRect = CGRectInset(self.pageViewController.view.frame, 40, 40); 

    if (CGRectContainsPoint(innerRect, touchPoint)) { 
     return NO; 
    } 

    return YES; 
}