GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - foby/DraggableCollectionView: Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
CircleLayoutDemo.xcodeproj
CircleLayoutDemo.xcodeproj
 
 
CircleLayoutDemo
CircleLayoutDemo
 
 
DraggableCollectionView
DraggableCollectionView
 
 
FlowLayoutDemo.xcodeproj
FlowLayoutDemo.xcodeproj
 
 
FlowLayoutDemo
FlowLayoutDemo
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

DraggableCollectionView

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop.

Getting Started

  • Include UICollectionView+Draggable catagory (and related files).
  • Include QuartzCoreFramework.
  • Set draggable to true on collection view.
  • Set collectionViewLayout to a layout that implements the UICollectionViewLayout_Warpable protocol (will fallback if layout does not). For the default Flow layout (grid) use DraggableCollectionViewFlowLayout - you can set this in Interface Builder.
  • Implement the UICollectionViewDataSource_Draggable extended protocol.

How it Works

It works just like UITableView. The extended protocol contains similarly named methods related to drag and drop found in the UITableViewDataSource protocol. The moveItemAtIndexPath:toIndexPath method is only called once - when the user lifts their finger. This is acomplished by "warping" the cells by modifying the output from the layoutAttributesForElementsInRect method. This allows you to physically move the cells around without touching the data source.

Custom Layouts

This extension can work with most custom layouts - just implement the UICollectionViewLayout_Warpable protocol. An easy way to do this is subclass your layout and feed the output from layoutAttributesForElementsInRect through LSCollectionViewLayoutHelper. For an example how to do this see DraggableCollectionViewFlowLayout - you can pretty much copy and paste from there. DraggableCollectionViewFlowLayout is included for Apple's default UICollectionViewFlowLayout (see FlowLayoutDemo). There is also CircleLayoutDemo for Apple's CircleLayout example from WWDC 2012.

License

DraggableCollectionView is available under the MIT license.

About

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop.

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.