GithubHelp home page GithubHelp logo

isabella232 / lxreorderablecollectionviewflowlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from minima/lxreorderablecollectionviewflowlayout

0.0 0.0 0.0 298 KB

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

Home Page: http://lxcid.com/

License: MIT License

lxreorderablecollectionviewflowlayout's Introduction

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

Screenshot

  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.

lxreorderablecollectionviewflowlayout's People

Contributors

cbess avatar charlietuna avatar jessecurry avatar lukescott avatar lxcid avatar sibljon avatar tonyarnold avatar

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.