Possible Duplicate:
UIButton long press with finger stationary
I have created 100 buttons from code. Now I want to react on long button press.
For each buttons I call enxt code:
UILongPressGestureRecognizer *longPressGesture = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(longPress:)]
autorelease];
[longPressGesture setMinimumPressDuration:1];
[button addGestureRecognizer:longPressGesture];
[self.view addSubview:button];
But longPress method was not called.
Does anybody know why?
It’s quite likely that
UIButtonalready uses a gesture recogniser for its touch handling. It’s also quite likely that the tap gesture succeeds before your long tap recogniser is allowed to see the touches, and therefore your long touch never gets called.My suggestion would be not use buttons and use views instead. You can add your long touch gesture recogniser to the view and change it’s appearance behaviour to look and feel like a button and be able to keep your long touch.