集合视图不称为didSelectItemAtIndexPath
。当我将Tap Gesture Recognizer添加到collectionView
超级视图时,它总是响应轻击手势方法。
请帮助我,提前致谢!
答案 0 :(得分:1)
试试这个
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
let touchPoint = touch.locationInView(superView)
return !CGRectContainsPoint(collectionView.frame, touchPoint)
}
并确保委托已连接:
tapGestureRecognizer.delegate = self