UILongPressGestureRecognizer有时会使其他手势的识别器失败

时间:2014-01-17 14:53:00

标签: ios iphone objective-c uigesturerecognizer

我的UILongPressGestureRecognizer有时会使其他手势的识别器失败。 我无法理解打破2单击手势识别器的确切模式。我想如果用户在我的UIImageView上点击了很多时间,就会发生这种情况。 我认为这与我的代码的逻辑有关......但我无法理解失败的位置。 感谢

 // adding tap gesture recognizers to the image view
    UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap)] autorelease];
    UITapGestureRecognizer *doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap)] autorelease];
    UILongPressGestureRecognizer *longTap = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlelongTap)] autorelease];

    [singleTap setNumberOfTapsRequired:1];
    [doubleTap setNumberOfTapsRequired:2];


    longTap.minimumPressDuration=0.70;
    longTap.numberOfTouchesRequired=1;



    [singleTap requireGestureRecognizerToFail:doubleTap];

    [singleTap requireGestureRecognizerToFail:longTap];
    [doubleTap requireGestureRecognizerToFail:longTap];

    [longTap requireGestureRecognizerToFail:singleTap];


    // adding drag and drop gesture recognizers to the image view
    UIGestureRecognizer *panGesture = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)] autorelease];

    //Adding gestures to the imageView
    [imageView addGestureRecognizer:singleTap];
    [imageView addGestureRecognizer:doubleTap];
    [imageView addGestureRecognizer:longTap];
    [imageView addGestureRecognizer:panGesture];

0 个答案:

没有答案