-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uninstall existing gesture recognizers when calling setupCollectionView
#117
Comments
I'm seeing this too, what's your solution @acruis ? |
For now I'm working around it by only injecting the layout in the If you have to set the Off the top of my head I have some wild hacks, but none of them are that nice:
class CustomFlowLayout: LXReorderableCollectionViewFlowLayout {
var settingCollectionView: Bool = false
override var collectionView: UICollectionView? {
let collectionView = super.collectionView
if let gestureRecognizer = self.panGestureRecognizer, self.settingCollectionView {
collectionView?.removeGestureRecognizer(gestureRecognizer)
}
return collectionView
}
}
...
// (when setting the flow layout)
let reorderableFlowLayout = CustomFlowLayout()
reodrerableFlowLayout.settingCollectionView = true
collectionView.collectionViewLayout = reorderableFlowLayout
reorderableFlowLayout.settingCollectionView = false I haven't tried this myself, so I'm not sure if it even works though.
|
There is a behaviour on the current iOS version (11.4, not sure when this behaviour started) where if a collection view's layout is set after initialization - instead of it being passed inside
init(frame:collectionViewLayout:)
- thecollectionView
property will be set twice.That is, if you do this
instead of this
KVO will cause
setupCollectionView
to be called twice. Consequently the storedpanGestureRecognizer
is replaced with a new one, but the old one is still listening to gestures on the collection view.This breaks scrolling, because scrolling over the collection view when
self.selectedItemIndexPath
isnil
should not triggerhandlePanGesture
, but it does because thisreturns
true
for the replaced (but still listening) pan gesture recognizer.The text was updated successfully, but these errors were encountered: