UICollectionView Swipe to remove iOS c target

I have already referenced this link Swipe in CollectionView

it is written quickly, i completed my project in lens c so i would like to continue in object c

I have a UICollectionView that has multiple labels. My goal is to present two delete and edit buttons as I scroll through the UICollectionView cell. I am dynamically issuing data for a collection.

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");
}

      

Now I have intercepted with a swipe gesture how to move a cell and present two buttons for editing and deleting targets.

I am getting "swipped" in my log when I scroll through the collection view cell

+3


source to share





All Articles