问题描述
我想在tapAnimation
上放一个CustomCollectionViewCell
,所以我在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,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
。但是,添加此选项后,我的didSelectItemAt
中的collectionView
将不再触发。知道我在做什么错吗?它不带override
代码段。
要添加:我实际上想在App Store中有一个动画(仅点击动画,而不是过渡动画!)
如果您需要更多信息,请告诉我!
解决方法
- 您在覆盖时忘记致电
super
。
例如:
override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) {
super.touchesBegan(touches,with: event)
....