我已经提到了这个链接Swipe to delete on CollectionView
它写得很快我已经在目标c中完成了我的项目所以我想继续在目标c
我有一个UICollectionView,它有一些标签。我的目的是当我滑动UICollectionView单元格时,向删除和编辑按钮提供两个按钮我动态地将数据提供给集合视图
以下是我的代码 -
- (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");
}
我现在拦截了滑动手势如何移动单元格并显示两个按钮以进行编辑和删除?
当我滑动我的集合视图单元格时,我在日志中“swipped”了