2013-04-17 61 views
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]]; 
} 

回答

2

cell的ImageView應該首先允許用戶交互來檢測水龍頭。確保你啓用了用戶與下面一行的交互。

[cell.imageView setUserInteractionEnabled:YES];