我的UICollectionView在滚动
后停止处理点击滚动
之后不再调用DidSelectoverride func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print("didSelectItemAt")
}
}
滚动后也不会调用单元格内的手势:
override open func awakeFromNib() {
// Initialization code
let tapUpInside = UITapGestureRecognizer.init(target: self, action: #selector(MainCollectionViewCell.tapPressButtonUP(_:)))
let longPress: UILongPressGestureRecognizer = UILongPressGestureRecognizer.init(target: self, action: #selector(MainCollectionViewCell.longPressButton(_:)))
longPress.delegate = self;
longPress.cancelsTouchesInView = false;
self.addGestureRecognizer(longPress)
}
答案 0 :(得分:1)
如果您在代理下面添加了自定义手势,则不会调用
覆盖func collectionView(_ collectionView:UICollectionView,didSelectItemAt indexPath:IndexPath){
对于问题的第二部分将手势添加到内容UICollectionView单元格视图并检查
self.contentView.addGestureRecognizer(longPress)
我建议您在UICollectionView上添加长按手势,然后确定哪个CollectionViewCell与长按点重叠,以便您可以获取所选的CollectionViewCell