I have UICollectionView on which i am displaying the custom cells.I am trying to move the cells by making long press gesture but it does not work at all.
I have followed this tutorial but it does not working for me.Please tell how to do this?
Long Press gesture
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
NSLog(@"long press geture called");
switch(gestureRecognizer.state)
{
case UIGestureRecognizerStateBegan:
p = [gestureRecognizer locationInView:self.collection_view];
gesture_indexPath = [self.collection_view indexPathForItemAtPoint:p];
[self.collection_view beginInteractiveMovementForItemAtIndexPath:gesture_indexPath];
NSLog(@"state began called");
break;
case UIGestureRecognizerStateChanged:
// collectionView.updateInteractiveMovementTargetPosition(gesture.locationInView(gesture.view!))
[self.collection_view updateInteractiveMovementTargetPosition:[gestureRecognizer locationInView:[gestureRecognizer view]]];
NSLog(@"state changed called");
case UIGestureRecognizerStateEnded:
[self.collection_view updateInteractiveMovementTargetPosition:p];
NSLog(@"state changed called");
default:
[self.collection_view cancelInteractiveMovement];
}
}
Method Overidden
-(void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
NSLog(@"Move at index path called");
}