Git Product home page Git Product logo

chucksaldana / htkdraganddropcollectionviewlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from henrytkirk/htkdraganddropcollectionviewlayout

0.0 2.0 0.0 268 KB

UICollectionViewLayout subclass that works together with a custom UICollectionViewCell to provide drag and drop for a UICollectionView. Works just like UITableView drag and drop. What's unique about this approach is that it does not need to create a "ghost" or "dummy" cell to provide the drag and drop functionality.

License: Apache License 2.0

Ruby 2.64% Objective-C 97.36%

htkdraganddropcollectionviewlayout's Introduction

HTKDragAndDropCollectionViewLayout

Custom UICollectionViewLayout that works together with a custom UICollectionViewCell to provide drag and drop for a UICollectionView. Works just like UITableView drag and drop. What's unique about this approach is that it does not need to create a "ghost" or "dummy" cell to provide the drag and drop functionality. I believe this method is simpler and less complex for the majority of use cases.

Adding to your project:

Cocoapods

CocoaPods is the recommended way to add HTKDragAndDropCollectionViewLayout to your project.

  1. Add a pod entry for HTKDragAndDropCollectionViewLayout to your Podfile pod 'HTKDragAndDropCollectionViewLayout'
  2. Install the pod(s) by running pod install.
  3. Subclass HTKDragAndDropCollectionViewController.
  4. Setup HTKDragAndDropCollectionViewLayout properties (itemSize, lineSpacing, etc).
  5. Subclass and use HTKDraggableCollectionViewCell which implements the gestures for dragging.
  6. Implement - (void)userDidEndDraggingCell:(UICollectionViewCell *)cell and if the HTKDragAndDropCollectionViewLayout finalIndexPath is not nil, insert the draggedIndexPath into the finalIndexPath's position. See example in project.

Sample video:

YouTube Sample Video

Screen shot:

Sample Screenshot

Change log:

v0.0.1: Initial project commit v0.1.0 - v0.1.2: Bug fixes - Don't use this version, I broke it. v0.1.3: Current stable version. This version is greatly enhanced over the original version. It now supports rotation, and inserting of items. Currently inserting only works to the "end" of the data source. So, if you have 10 items in your collectionView and wish to insert, adding the item to indexPath 0,10 will work fine, while adding to indexPath 0,5 would not. This should be corrected pretty soon.

Questions? Email: [email protected] or Web: http://www.henrytkirk.info

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.