0

У меня есть пользовательская реализация UITableViewCell. UITableViewCell можно прокручивать влево или вправо. Я использую UIPanGestureRecognizer для этого же.проведите пальцем по одному пальцу и проведите пальцем по одному подклассу UIView

UIGestureRecognizer* recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; 
     recognizer.delegate = self; 
     [self addGestureRecognizer:recognizer]; 

      } 

#pragma mark - horizontal pan gesture methods 
-(BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer { 
    CGPoint translation = [gestureRecognizer translationInView:[self superview]]; 
    // Check for horizontal gesture 
    if (fabsf(translation.x) > fabsf(translation.y)) { 
     return YES; 
    } 
    return NO; 
} 

-(void)handlePan:(UIPanGestureRecognizer *)recognizer { 
    if (recognizer.state == UIGestureRecognizerStateBegan) { 
    // if the gesture has just started, record the current centre location 
     // SOME CODE 
    } 

    if (recognizer.state == UIGestureRecognizerStateChanged) { 
     // translate the center 
     //SOME CODE 
    } 

    if (recognizer.state == UIGestureRecognizerStateEnded) { 
     // the frame this cell would have had before being dragged 
     //SOME CODE 
    } 
} 

Теперь я хочу, чтобы иметь возможность поддерживать два пальца на на весь экран, что даже если два пальца делается на UITableViewCell, приведенный выше код не срабатывает. Как я могу это достичь?

+0

Вы уверены, что ваш «Проверка горизонтального жеста» логика верна? – sunkehappy

ответ

1

Если вы установите maximumNumberOfTouches на ваш жест распознаватель к 1, он больше не будет принимать мульти-палец пойло:

UIGestureRecognizer* recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; 
recognizer.maximumNumberOfTouches = 1; 
Смежные вопросы