Double tap on a UIButton [duplicate]
Possible Duplicate:
Double tap on a button
Hi, I find on foruns that to me detect 2 taps I use this code:
- (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event
{
UITouch *touch = [touches anyObject];
if (touch.tapCount == 2)
{
nosi=nosi-1;
if (nosi<10) {
nos.text = [NSString stringWithFormat:@"0%i", nosi];
} else {
nos.text = [NSString stringWithFormat:@"%i", nosi];
}开发者_高级运维
}
}
But, how I detect 2 taps in a button ?
subclass UIButton and put that code in ;)
but I think that's kind of a strange UI experience, double tapping a button.
I answered this question already once today...
Use UITapGestureRecognizer...
Granted it's only available for recent iOS, don't try it on 3.0;)
精彩评论