I\'m building an iPhone app that would let the user rearrange some of the UI elements on the screen.
How can I add a tap gesture recognizer and a long press gesture rec
I did try moby and journeyman's approach but somehow they didn't fit my project well, so I solved like below,
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
NSLog(@"%@ %ld",touch.description, touch.phase);
[self performSelector:@selector(checkTouch:) withObject:touch afterDelay:0.5];
return YES;
}
and
- (void)checkTouch:(UITouch *)touch{
NSLog(@"touch phase = %ld",touch.phase);
if (touch.phase == UITouchPhaseStationary) {
//still holding my hand and this means I wanted longPressTouch
}
if (touch.phase == UITouchPhaseEnded){
//I released my finger so it's obviously tap
}
}
It could be simpler solution but of course it depends to project.