Task
Add one sign gestures to the UICollectionView ; don't interfere with cell selection.
I want some other taps on the non-element part of the View collection.
The code
Using Xcode8, Swift 3.
override func viewDidLoad() { ... collectionView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tap))) } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { print(indexPath) } func tap(sender: UITapGestureRecognizer){ print("tapped") }
Result
Yes, now it interferes. When you click on a cell, it records "tapping."
Analysis
- I check the return value of the hitTest of the collection and cell. Both returned the selected cell, which means that they form a chain of responders Cell → CollectionView
- no gestures in the cell
- 3 gestures in the View collection, no one works with cell selection
- UIScrollViewDelayedTouchesBeganGestureRecognizer
- UIScrollViewPanGestureRecognizer
- UITapGestureRecognizer
- callStack, it seems that the cell selection has a different stack trace with the target gesture action pattern.
- A double-tap gesture works with cell selection.
Question
Could not find more trace. Any ideas on how cell selection is done or to achieve this?
ios swift uicollectionview uigesturerecognizer uiresponder
jchnxu
source share