0

这就是我所拥有的

UICollectionViewController - UICollectionViewCell - UIScrollView - ImageView

我正在尝试处理对 imageview 的点击,但从未被调用。

UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[cell.imageView addGestureRecognizer:tap];

- (void)handleTap:(UITapGestureRecognizer *)recognizer  {
    NSLog(@"Tap");
    NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:[recognizer locationInView:self.collectionView]];
}
4

1 回答 1

2

单元格的 ImageView 应该首先允许用户交互来检测点击。确保您启用与以下行的用户交互。

[cell.imageView setUserInteractionEnabled:YES];
于 2013-04-17T21:33:16.603 回答