繁体   English   中英

手势识别器永远不会发射

[英]Gesture Recognizer never fires

这就是我所拥有的

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

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

[cell.imageView setUserInteractionEnabled:YES];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM