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.
精彩评论