开发者

How do i detect a long press?

开发者 https://www.devze.com 2023-02-17 18:27 出处:网络
I\'开发者_运维知识库m wondering how I should go about detecting a long press on a UIButton I have? I\'ve heard of UILongPressGestureRecognizer but am totally unsure how to use it.Use this:

I'开发者_运维知识库m wondering how I should go about detecting a long press on a UIButton I have? I've heard of UILongPressGestureRecognizer but am totally unsure how to use it.


Use this:

UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(selectorname)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];


I'm not sure about the UILongPressGestureRecognizer, but you could start a NSTimer when the button is hit, and then when the timer goes off check to see if it is still down.

0

精彩评论

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