开发者

Double tap on a UIButton [duplicate]

开发者 https://www.devze.com 2023-02-23 14:26 出处:网络
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:
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

精彩评论

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