这就是我所拥有的
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]];
}
答案 0 :(得分:2)
单元格的ImageView应该首先允许用户交互来检测点击。确保使用以下行启用用户交互。
[cell.imageView setUserInteractionEnabled:YES];