UICollectionView effective drag and drop

前端 未结 5 1969
半阙折子戏
半阙折子戏 2021-01-29 17:56

I am currently trying to implement the UITableView reordering behavior using UICollectionView.

Let\'s call a UItableView TV and a UICollectionVi

5条回答
  •  青春惊慌失措
    2021-01-29 18:43

    Here is an alternative:

    The differences between DraggableCollectionView and LXReorderableCollectionViewFlowLayout are:

    • The data source is only changed once. This means that while the user is dragging an item the cells are re-positioned without modifying the data source.
    • It's written in such a way that makes it possible to use with custom layouts.
    • It uses a CADisplayLink for smooth scrolling and animation.
    • Animations are canceled less frequently while dragging. It feels more "natural".
    • The protocol extends UICollectionViewDataSource with methods similar to UITableViewDataSource.

    It's a work in progress. Multiple sections are now supported.

    To use it with a custom layout see DraggableCollectionViewFlowLayout. Most of the logic exists in LSCollectionViewLayoutHelper. There is also an example in CircleLayoutDemo showing how to make Apple's CircleLayout example from WWDC 2012 work.

提交回复
热议问题