LXReorderableCollectionViewFlowLayout

Extends `UICollectionViewFlowLayout` to support reordering of cells. Similar to long press and pan on books in iBook.

Github星跟蹤圖

LXReorderableCollectionViewFlowLayout

Extends UICollectionViewFlowLayout to support reordering of cells. Similar to long press and pan on books in iBook.

Features

The goal of LXReorderableCollectionViewFlowLayout is to provides capability for reordering of cell, similar to iBook.

  • Long press on cell to invoke reordering capability.
  • When reordering capability is invoked, fade the selected cell from highlighted to normal state.
  • Drag around the selected cell to move it to the desired location, the other cells adjust accordingly. Callback in the form of delegate methods are invoked.
  • Drag selected cell to the edges, depending on scroll direction, scroll in the desired direction.
  • Release to stop reordering.

Getting Started

  1. Install using CocoaPods or drag the LXReorderableCollectionViewFlowLayout folder into your project.

  2. Initialize/Setup your collection view to use LXReorderableCollectionViewFlowLayout.

  3. The collection view controller that is to support reordering capability must conforms to LXReorderableCollectionViewDataSource protocol. For example,

    - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
        id object = [mutableArray objectAtIndex:fromIndexPath.item];
        [mutableArray removeObjectAtIndex:fromIndexPath.item];
        [mutableArray insertObject:object atIndex:toIndexPath.item];
    }
    
  4. You can listen to some dragging events through comforming to LXReorderableCollectionViewDelegateFlowLayout methods.

  5. Setup your collection view accordingly to your need, run and see it in action! :D

Changes

Feb 24 2013 (Luke Scott)

  • Removed setUpGestureRecognizersOnCollectionView
  • Removed layout from delegate methods (can be accessed from collectionView)
  • Renamed delegate methods and split between dataSource and delegate
  • Added dataSource and delegate examples to sample project

Feb 23 2013 (Luke Scott)

  • Refactored everything to be more readable / maintainable
  • Deprecated setUpGestureRecognizersOnCollectionView - no longer necessary

Requirements

  • ARC
  • iOS 6 and above preferred
  • Xcode 4.5 and above

Credits

Alternatives

License

LXReorderableCollectionViewFlowLayout is available under the MIT license.

主要指標

概覽
名稱與所有者lxcid/LXReorderableCollectionViewFlowLayout
主編程語言Objective-C
編程語言Objective-C (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2012-10-02 16:09:14
推送於2019-03-08 13:01:46
最后一次提交2017-05-19 23:37:13
發布數8
最新版本名稱0.2.1 (發布於 2017-05-19 23:37:22)
第一版名稱0.0.1 (發布於 2013-02-10 01:31:10)
用户参与
星數1.9k
關注者數75
派生數325
提交數98
已啟用問題?
問題數79
打開的問題數46
拉請求數18
打開的拉請求數10
關閉的拉請求數11
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?