I have a UIScrollView
with numerous stack subviews.
I have a UITapGestureRecognizer
that dismisses the keyboard and this works.
let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKbd))
self.view.addGestureRecognizer(tap)
One of my subviews is a stack view that holds a collection view.
stackView = UIStackView()
scrollView.addSubview(stackView)
stackView.axis = .horizontal
stackView.anchor(top: notesTextView.bottomAnchor, left: scrollView.leftAnchor, bottom: scrollView.bottomAnchor, right: scrollView.rightAnchor, paddingTop: 8, paddingLeft: 2, paddingBottom: 2, paddingRight: 2, height: 400)
let child = ImageGalleryViewController()
stackView.addArrangedSubview(child.view)
child.didMove(toParent: self)
Problem:
This results in:
- Keyboard will dismiss when screen tapped
didSelectItemAt
only works when two fingers are used on a cell
I assume this is to do with a conflict of gesture recognizers.
I would appreciate any guidance on how to make this work. I assume it's to do with the focus of the gesture recognizers?
question from:
https://stackoverflow.com/questions/65859275/uitapgesturerecognizer-dismiss-keyboard-uicollectionview-conflict 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…