Andrew
Andrew

Reputation: 16051

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.

Upvotes: 2

Views: 1492

Answers (2)

Nathan S.
Nathan S.

Reputation: 5388

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.

Upvotes: 3

Vin
Vin

Reputation: 10548

Use this:

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

Upvotes: 7

Related Questions