双击CollectionViewCell时如何制作活动?

时间:2015-09-05 04:22:16

标签: ios uicollectionview uicollectionviewcell

我想在双击collectionview单元格时发生一个事件

UIGestureRecognizer是解决此问题的唯一方法吗?

这是我需要解决的非常漫长而艰难的代码...

UICollectionViewUICollectionViewCell是否有任何支持?

1 个答案:

答案 0 :(得分:0)

在你的-cellForRowAtIndexPath中:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTapped:)];
    tap.numberOfTapsRequired = 2;
    [cell addGestureRecognizer:tap];

这个方法:

    -(void)doubleTapped:(UITapGestureRecognizer*)tap{
        UICollectionViewCell *doubleTappedCell = tap.view;
        NSIndexPath *indexPath = [self.collectionView indexPathForCell:doubleTappedCell];
}