HXCollectionView.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // HXCollectionView.h
  3. // HXPhotoPickerExample
  4. //
  5. // Created by Silence on 17/2/17.
  6. // Copyright © 2017年 Silence. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class HXCollectionView;
  10. @protocol HXCollectionViewDelegate <UICollectionViewDelegate>
  11. @required
  12. /**
  13. * 当数据源更新的到时候调用,必须实现,需将新的数据源设置为当前的数据源(例如 :_data = newDataArray)
  14. * @param newDataArray 更新后的数据源
  15. */
  16. - (void)dragCellCollectionView:(HXCollectionView *)collectionView newDataArrayAfterMove:(NSArray *)newDataArray;
  17. @optional
  18. /**
  19. * cell移动完毕,并成功移动到新位置的时候调用
  20. */
  21. - (void)dragCellCollectionViewCellEndMoving:(HXCollectionView *)collectionView;
  22. /**
  23. * 成功交换了位置的时候调用
  24. * @param fromIndexPath 交换cell的起始位置
  25. * @param toIndexPath 交换cell的新位置
  26. */
  27. - (void)dragCellCollectionView:(HXCollectionView *)collectionView moveCellFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath;
  28. /**
  29. 长按手势结束时是否删除当前拖动的cell
  30. @param collectionView 视图本身
  31. @return 是否删除
  32. */
  33. - (BOOL)collectionViewShouldDeleteCurrentMoveItem:(UICollectionView *)collectionView gestureRecognizer:(UILongPressGestureRecognizer *)longPgr indexPath:(NSIndexPath *)indexPath;
  34. /**
  35. 长按手势发生改变时调用
  36. @param collectionView 视图本身
  37. @param longPgr 长按手势识别器
  38. */
  39. - (void)collectionView:(UICollectionView *)collectionView gestureRecognizerChange:(UILongPressGestureRecognizer *)longPgr indexPath:(NSIndexPath *)indexPath;
  40. /**
  41. 长按手势开始时调用
  42. @param collectionView 视图本身
  43. @param longPgr 长按手势识别器
  44. */
  45. - (void)collectionView:(UICollectionView *)collectionView gestureRecognizerBegan:(UILongPressGestureRecognizer *)longPgr indexPath:(NSIndexPath *)indexPath;
  46. /**
  47. 长按手势结束时调用
  48. @param collectionView 视图本身
  49. @param longPgr 长按手势识别器
  50. */
  51. - (void)collectionView:(UICollectionView *)collectionView gestureRecognizerEnded:(UILongPressGestureRecognizer *)longPgr indexPath:(NSIndexPath *)indexPath;
  52. - (void)collectionViewNeedReloadData:(UICollectionView *)collectionView;
  53. @end
  54. @protocol HXCollectionViewDataSource<UICollectionViewDataSource>
  55. @required
  56. /**
  57. * 返回整个CollectionView的数据,必须实现,需根据数据进行移动后的数据重排
  58. */
  59. - (NSArray *)dataSourceArrayOfCollectionView:(HXCollectionView *)collectionView;
  60. @end
  61. @interface HXCollectionView : UICollectionView
  62. @property (weak, nonatomic) id<HXCollectionViewDelegate> delegate;
  63. @property (weak, nonatomic) id<HXCollectionViewDataSource> dataSource;
  64. @property (assign, nonatomic) BOOL editEnabled;
  65. @end