Comments (2)
I'm seeing this too, what's your solution @acruis ?
from lxreorderablecollectionviewflowlayout.
For now I'm working around it by only injecting the layout in the init
(basically the snippet below "instead of this").
If you have to set the collectionViewLayout
manually then...I'm not sure there's much you can do. The layout does expose its gesture recognizers but setupCollectionView
sets the ivars directly instead of calling the property setters, which means you can't rely on KVO.
Off the top of my head I have some wild hacks, but none of them are that nice:
- Since the KVO method has a check for
if (self.collectionView != nil) {
, you can subclassLXReorderableCollectionViewFlowLayout
and override the getter ofcollectionView
, which lets you run some code before the gesture recognizers go stale, something like:
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.
- You might also be able to subclass
UICollectionView
to override theaddGestureRecognizer
call to somehow keep track of existing gesture recognizers and remove stale ones accordingly, but if you go that far... - ...you might as well just make copies of the collection view and switch between them when you need to change the layout.
from lxreorderablecollectionviewflowlayout.
Related Issues (20)
- Conflict with IOS 9 introduced functions
- Crash when reorder cell between section HOT 2
- crash with move item from section1 to section2, HOT 1
- Used by Instagram
- Save cell order?
- paging feature?
- LongPress show whiteItem which you pressed in iPhone7 HOT 3
- Lock Cells while Dragging
- Maybe need optimization HOT 1
- Latest PR that was merged in does not compile HOT 1
- Could you update podspec to make sure pod update can get this new release? HOT 1
- Compilation error in version 0.2.0 HOT 3
- Add Drag and drop function HOT 1
- UICollectionView scroll no longer works under iOS 9.0b HOT 3
- iOS 9 crash HOT 8
- Stop Items to scroll back when one cell is picked Up
- closed HOT 1
- How to use in NSFetchResultController.
- Linking Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lxreorderablecollectionviewflowlayout.