2016-11-30 80 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