我如何检测长按?

And*_*rew 2 iphone objective-c uibutton

我想知道如何检测我对UIButton的长按?我听说过UILongPressGestureRecognizer但我完全不确定如何使用它.

Vin*_*Vin 7

用这个:

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