最近在做項目的時候無論是簡單的添加一個長按手勢,還是在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];
??? }
}