我想知道如何检测我对UIButton的长按?我听说过UILongPressGestureRecognizer,但完全不确定如何使用它。
答案 0 :(得分:7)
使用此:
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(selectorname)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];
答案 1 :(得分:3)
我不确定UILongPressGestureRecognizer
,但你可以在按下按钮时启动NSTimer
,然后当计时器熄灭时检查它是否仍然按下。