3

I have already referred this link Swipe to delete on CollectionView

it is written in swift I have done my project in objective c so I would like to continue in objective c

I have a UICollectionView which has some labels.My aim is to present two buttons a delete and edit button when I swipe the UICollectionView cell I am giving data to collection view dynamically

Below is my code-

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//int i=[self.name count];
return 5;

}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
AllProCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.buttondel.hidden=YES;
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;
[cell addGestureRecognizer:swipeGesture];
cell.pcatelbl.text=[NSString stringWithFormat:@"test"];
return cell;
}

-(void) handleSwipeGesture:(UISwipeGestureRecognizer *) sender
{

    NSLog(@"swipped");
}

I have intercepted the swipe gesture now how to I move the cell and present two buttons for editing and deleting purposes???

I am getting "swipped" in my log when I swipe my collection view cell

Akshay
  • 179
  • 1
  • 16

0 Answers0