开发者

How do i detect a long press?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜