我有一個自定義的方法來檢測單元格的圖像上的一個水龍頭。我也想找到圖像相關單元的索引路徑,並在函數內使用它。這裏是我使用的是什麼:indexView的tableViewCell
的cellForRowAtIndexPath:
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellImageTapped:)];
tapped.numberOfTapsRequired = 1;
[cell.imageView addGestureRecognizer:tapped];
方法,我嘗試在獲得索引路徑:
-(void)cellImageTapped:(id)sender {
if(videoArray.count > 0){
Video *currentVideo = [videoArray objectAtIndex:INDEX_PATH_OF_CELL_IMAGE];
//do some stuff
}
}
我不知道如何通過索引路徑。有任何想法嗎?
我其實,我只是沒有列出來,但我沒有我的函數中獲得細胞。 –
您可以訪問imageView。在cellImageTapped:方法中使用(((UITapGestureRecognizer *)sender).view.tag。輕擊手勢識別器的視圖是被點擊的imageView。 – paulrehkugler
這是假設在tableView中只有一個部分 – StevenTsooo