I'm having an interesting problem with a long press gesture recognizer. I placed one of these on a UITableView, and it only works when I lift my finger after the long press. So basically, I would place my finger on a cell, and then when I lift my finger, it triggers the long press. I figured this out by putting printn
s when the long press began and ended and both fire after I lift my finger. I think the tableViews default panGestureRecognizer
might be interfering with the longPressGestureRecognizer
. Here is my code in viewDidLoad
:
var longPress:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
longPress.minimumPressDuration = 0.06
longPress.delegate = self
self.tableView.addGestureRecognizer(longPress)
longPress.requireGestureRecognizerToFail(self.tableView.panGestureRecognizer)
触摸单元格不会导致表格视图的panGestureRecognizer失败,因此删除requireGestureRecognizerToFail方法,然后在手指仍然按下时应该进入.Began状态。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.