2016-11-30 71 views
1

我UICollectionView停止滚动后处理自来水UICollectionView不能选择

DidSelect不滚动后不再叫

override 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) 
    } 

回答

1

正如你所添加以下代表自定义手势不叫

覆盖FUNC的CollectionView(_的CollectionView:UICollectionView,didSelectItemAt indexPath:IndexPath){

你的问题的第二部分的姿态加入UICollectionView细胞的内容查看和检查

self.contentView.addGestureRecognizer(longPress) 

我推荐您在UICollectionView上添加长按手势,然后确定哪个CollectionViewCell与长按点重叠,以便您可以获取选定的CollectionViewCell