UILongPressGestureRecognizer does not work, but its replacement for UITapGestureRecognizer works fine. What for?

I have one UIImageViewwith an attached UILongPressGestureRecognizerone that never detects a long click gesture no matter how I set up the gesture recognizer. However, if I change it to UITapGestureRecognizer, which is working fine. What could happen?

Here's how I set up my own UILongPressGestureRecognizer:

UIImageView* cellView = (UIImageView*)[view viewWithTag:5];
UILongPressGestureRecognizer* longPressGestureRec =
    [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellLongPress:)];
longPressGestureRec.numberOfTapsRequired = 1;
longPressGestureRec.numberOfTouchesRequired = 1;
longPressGestureRec.minimumPressDuration = 0.4;
[cellView addGestureRecognizer:longPressGestureRec];
[longPressGestureRec release];

Here's what it looks like cellLongPress:

-(void)cellLongPress:(UILongPressGestureRecognizer*)recognizer
{
    // This never gets called.
    NSLog(@"someone long pressed me");
}

Pretty simple, right? However, until it turned out that it works. Any ideas?

+5
source share
1 answer

numberOfTapsRequired 1, , , ( , , 0,4 , ).

numberOfTapsRequired 0 ( ).

:

, .

UILongPressGestureRecognizer.h :

,

+22

All Articles