开发者

Double tap on a UIButton [duplicate]

This question already has answers here: Closed 11 years ago.

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;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜