ios UILongPressGestureRecognizer长按事件 (2013-02-21 16:10:41)转载▼
标签: uilongpressgesturere 长按事件 分类: ios
- (void)viewDidLoad
{
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressBtn:)];
[longPressGesture setDelegate:self];
longPressGesture.minimumPressDuration=1;//默认0.5秒
[m_btnSpeak addGestureRecognizer:longPressGesture];
[longPressGesture release];
}
//长按后触发该方法
-(void)longPressBtn:(UILongPressGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
//长按事件开始"
//do something
}
else if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) {
//长按事件结束
//do something
}
}