这就是我所拥有的

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]];
}

===============>>#1 票数:2 已采纳

cell的ImageView应首先允许用户交互来检测点击。 确保使用以下行启用用户交互。

[cell.imageView setUserInteractionEnabled:YES];

  ask by user1688346 translate from so

未解决问题?本站智能推荐: