簡體   English   中英

Swift CollectionView didSelectItemAt 在覆蓋單元格中的觸摸后不再工作

[英]Swift CollectionView didSelectItemAt no longer working after overriding touch in cell

我想在我的CustomCollectionViewCell上有一個tapAnimation ,所以我在class添加了這些行:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    UIView.animate(withDuration: 0.05, delay: 0, options: .curveEaseInOut) {
        self.theView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
    }
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    UIView.animate(withDuration: 0.1, delay: 0, options: .curveEaseInOut) {
        self.theView.transform = CGAffineTransform(scaleX: 1, y: 1)
    }
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    UIView.animate(withDuration: 0.1) {
        self.theView.transform = CGAffineTransform(scaleX: 1, y: 1)
    }
}

theView幾乎是這里的整個cell 但是在添加這個之后,我的collectionView didSelectItemAt不再觸發。 知道我在這里做錯了什么嗎? 它在沒有override -snippets 的情況下工作。

補充:我實際上想要一個像 App-Store 中的動畫(只有點擊動畫,沒有過渡!)

如果您需要更多信息,請告訴我!

  • 你忘記在覆蓋時調用super

前任:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)
    ....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM