我在單元格中使用UILongPressGestureRecognizer。 我需要的是:當用戶點擊一個單元格1.0秒時,調用一個視圖控制器。 如果用戶點擊該單元,則另一個VC。UITableViewCell上的UILongPressGestureRecognizer - 雙重調用
我可以通過使用UILongPressGestureRecognizer來實現。但問題是,這是調用viewController兩次。
代碼:
if (indexPath.section == 0 && indexPath.row == 1){
UILongPressGestureRecognizer *longPressTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(memberListWithSearchOptions)];
longPressTap.minimumPressDuration = 1.0;
[cell addGestureRecognizer:longPressTap];
[longPressTap release];
}
我想,我需要的是,認識到長按之後,禁用識別,直到上的tableView屏幕再次出現。
我該怎麼做?
感謝,
RL
手勢識別器解釋的手勢可以是* discrete *或* continuous *。像UILongPressGestureRecognizer這樣的連續的手勢識別器可以多次觸發它們的動作方法。如果手勢開始時你想做一些邏輯或者UIGestureRecognizerEnded,你可以檢查手勢識別器的'state'屬性是否設置爲'UIGestureRecognizerBegan' '當手勢完成時做一些邏輯。 – albertamg