Giter Site home page Giter Site logo

Comments (2)

ryderjack avatar ryderjack commented on May 24, 2024

I'm seeing this too, what's your solution @acruis ?

from lxreorderablecollectionviewflowlayout.

acruis avatar acruis commented on May 24, 2024

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:

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 the addGestureRecognizer 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.