0

我有一个 UIPageViewController 并且每个页面在页面上包含多个 UIViews,每个 UIView 允许在 longPress 手势后平移手势,我在 contentVC 中使用以下委托,但看起来 pageVC 不关心我下面的限制,它继续翻转这页纸!我在平移时是否必须做任何事情来禁用翻页?(最后的手段是像 canTurn 一样在 PageVC 上设置一个变量,并在平移运行时将其设置为 NO....

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

    if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] &&
        [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        return YES;
    }
    return NO;
}
4

1 回答 1

1

您应该-gestureRecognizer:shouldReceiveTouch:在 PageVC 本身中添加该方法,或者如果您不想在 PageVC 本身中添加它,您可以让委托处理它

像:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
   if(someCase)
   {
      return yes;
   }

   return no;
}

或者

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
   return [delegate shouldHandle:.....];
}
于 2012-05-21T18:50:59.840 回答