最近在做项目的时候无论是简单的添加一个长按手势,还是在cell上添加长按手势,再触发方法后总是调用不止一次,处理方法如下:
- (void)btnLongPress:(UILongPressGestureRecognizer *)longPress
{
// DLog(@"%@",longPress.view);
UIButton *btn = (UIButton *)longPress.view;
if ([longPress state] == UIGestureRecognizerStateBegan) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"是否将目前灯光设置存储在%@环境下?",btn.titleLabel.text] delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
alert.tag = longPress.view.tag;
[alert show];
}
}