Giter Site home page Giter Site logo

liangdahong / bmlongpressdragcellcollectionview Goto Github PK

View Code? Open in Web Editor NEW
1.2K 19.0 190.0 55.18 MB

🎉 🎉 🎉 🎉 🎉 让你轻松实现类似支付宝的拖拽重排功能, 支持各种自定义操作。

License: MIT License

Objective-C 96.39% Ruby 0.82% Shell 0.27% Swift 2.53%
uicollectionview uicollectionviewcell drag rearrangement objective-c arrangement

bmlongpressdragcellcollectionview's Introduction

English version

介绍

  • 本框架是一个让你轻松实现类似支付宝的拖拽重排功能,支持自定义,iOS8+,具体可查看代码。

CocoaPods 安装

pod 'BMLongPressDragCellCollectionView'
pod install
#import "BMLongPressDragCellCollectionView.h"

手动安装

  • 下载项目 「 clone https://github.com/liangdahong/BMLongPressDragCellCollectionView.git
  • BMLongPressDragCellCollectionView 文件夹下的全部内容拖拽到你的项目。

使用说明

  1. BMLongPressDragCellCollectionView 是继自 UICollectionView ,其使用方式和 UICollectionView 一致,只需要把 UICollectionView 修改为 BMLongPressDragCellCollectionView 即可【支持 Xib,StoryBoard】。
  2. 原来的 UICollectionViewDataSource 换为 BMLongPressDragCellCollectionViewDataSource
  3. 原来的 UICollectionViewDelegateFlowLayout 换为 BMLongPressDragCellCollectionViewDelegate
  4. 实现数据源方法,内部会使用此方法获取数据源,必须实现,之所以设计为 NSArray< NSArray<id> *> * 的数据结构是因为内部要对 cell 【数据源】做排序处理。
- (NSArray< NSArray<id> *> *)dataSourceWithDragCellCollectionView:(__kindof BMLongPressDragCellCollectionView *)dragCellCollectionView;

如下:

- (NSArray<NSArray<id> *> *)dataSourceWithDragCellCollectionView:(__kindof BMLongPressDragCellCollectionView *)dragCellCollectionView {
    return self.dataSourceArray;
}
  1. 实现代理方法,当 Cell 有交换时调用,需要外面保存最新的数据源【如果有交换时,数据源已经更新】,必须实现。
- (void)dragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView newDataArrayAfterMove:(nullable NSArray< NSArray<id> *> *)newDataArray;

如下:

- (void)dragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView newDataArrayAfterMove:(nullable NSArray< NSArray<id> *> *)newDataArray {
    self.dataSourceArray = [newDataArray mutableCopy];
}

图文演示

Xib或者 StoryBoard 中使用

  • Xib或者 StoryBoard 中只需要上面的 3 步就可以让你的 UICollectionView 完美支持拖拽重排了。

使用纯代码实现

  • 在纯代码实现中只需要上面的 3 步 就可以让你的 UICollectionView 完美支持拖拽重排了。

更多自定义方案

如果要做一些自定义的操作可以通过设置 BMLongPressDragCellCollectionView 的相关属性或者实现一些特定的协议方法来处理,可查看 BMLongPressDragCellCollectionView 的头文件和 BMLongPressDragCellCollectionViewDelegateBMLongPressDragCellCollectionViewDataSource 协议。

联系

  • 欢迎 issuesPR
  • 也可以添加微信 进微信交流群。

其他

  • 定个小目标 😂 2020年08月05日 纯 Swift 正在计划中...

感谢

相关推荐

License

BMLongPressDragCellCollectionView is released under the MIT license. See LICENSE for details.

广告时间 😁,下面是我开发的几款小程序,感兴趣的可以看看,点点广告就更好了,哈哈哈~~~

  • 便捷的日历小程序,支持节假日,调休等
  • rl

  • 便捷的工资扣税计算器。
  • jsq

bmlongpressdragcellcollectionview's People

Contributors

aheze avatar liangdahong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bmlongpressdragcellcollectionview's Issues

collectionView自动滚动动画

复现步骤: 单分区情况,Alipay1数据源创建几十个,cell高度超过屏幕高度,定时器自动滚动的动画问题。
多分区Demo演示无此问题。

内存不释放

用这个框架之后,pop控制器后,控制器不走delloc方法,必须手动 BMLongPressDragCellCollectionView removeFromSuperView
BMLongPressDragCellCollectionView = nil 才行

TableView 嵌套 CollectionView 如何控制contentOffset

我是在tableview cell 上面嵌套了一个collectionview,高度是通过显示计算出来的,但是比较长的情况下,还是需要让外面的tablview 移动一下,不然影响体验。请问有什么办法可以实现吗?

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.