UIGestureRecognizer确定点击

时间:2016-05-31 06:14:37

标签: ios uigesturerecognizer

我在SO上跟踪了这个答案:set

但我收到错误“预期表达”。我做错了什么?

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
{
    BOOL shouldReceiveTouch = YES;

    if (gestureRecognizer == tap) { //Expected Expression
        shouldReceiveTouch = (touch.view == _shownImage);
    }
    return shouldReceiveTouch;
}

2 个答案:

答案 0 :(得分:1)

您可以查看UIGestureRecognizer类

-(BOOL) gestureRecognizer: (UIGestureRecognize *) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer: (UIGestureRecognizer *) otherGestureRecognizer {
if ([gestureRecognizer isMemberOfClass: [UITapGestureRecognizer class]]) {

shouldReceiveTouch = (touch.view == _shownImage);    

     }
}

答案 1 :(得分:1)

您必须tap(UITapGestureRecognizer)检查UIGestureRecognizer手势是isMemberOfClass的成员。

-(BOOL) gestureRecognizer: (UIGestureRecognize *) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer: (UIGestureRecognizer *) otherGestureRecognizer {
    if ([gestureRecognizer isMemberOfClass: [tap class]]) {// please check this one
    }
   }