0

これは私が持っているものです

UICollectionViewController - UICollectionViewCell - UIScrollView - 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 に答える