RAReorderableLayout
RAReorderableLayout copied to clipboard
Please Provide Obj-c exmple
For version 0.6.1 with Swift 3.0
1.Added @objc before
public protocol RAReorderableLayoutDelegate: UICollectionViewDelegateFlowLayout
and
public protocol RAReorderableLayoutDataSource: UICollectionViewDataSource
the code will be:
@objc public protocol RAReorderableLayoutDelegate: UICollectionViewDelegateFlowLayout
@objc public protocol RAReorderableLayoutDataSource: UICollectionViewDataSource
2.setup your collection view delegate and datasource(Use RAReorderableLayout as its layout)
collectionView.delegate = self;
collectionVeiw.datasource = self;
You don't need to do something like
layout.delegate = self
at this version
3.Put all the delegate & datasource method into your view controller
Datasource:
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAt:(NSIndexPath *)indexPath;
- (CGFloat)collectionView:(UICollectionView *)collectionView reorderingItemAlphaInSection:(NSInteger)section;
- (UIEdgeInsets)scrollTrigerPaddingInCollectionView:(UICollectionView *)collectionView;
- (UIEdgeInsets)scrollTrigerEdgeInsetsInCollectionView:(UICollectionView *)collectionView;
- (CGFloat)scrollSpeedValueInCollectionView:(UICollectionView *)collectionView;
Delegate:
- (BOOL)collectionView:(UICollectionView *)collectionView allowMoveAt:(NSIndexPath *)indexPath;
- (BOOL)collectionView:(UICollectionView *)collectionView at:(NSIndexPath * _Nonnull)at canMoveTo:(NSIndexPath * _Nonnull)canMoveTo;
- (void)collectionView:(UICollectionView *)collectionView at:(NSIndexPath *)at didMoveTo:(NSIndexPath *)toIndexPath;
- (void)collectionView:(UICollectionView *)collectionView collectionView:(RAReorderableLayout *)layout willEndDraggingItemTo:(NSIndexPath * _Nonnull)indexPath;
- (void)collectionView:(UICollectionView *)collectionView collectionView:(RAReorderableLayout *)layout didEndDraggingItemTo:(NSIndexPath *)indexPath;
- (void)collectionView:(UICollectionView *)collectionView collectionView:(RAReorderableLayout *)layout willBeginDraggingItemAt:(NSIndexPath *)indexPath;
- (void)collectionView:(UICollectionView *)collectionView collectionView:(RAReorderableLayout *)layout didBeginDraggingItemAt:(NSIndexPath * _Nonnull)indexPath;
- (void)collectionView:(UICollectionView *)collectionView at:(NSIndexPath * _Nonnull)at willMoveTo:(NSIndexPath * _Nonnull)toIndexPath;
Then do what you need in all these methods. P.S. some method you don't need could be just empty