UICollectionView セルのタップを処理したい。次のコードを使用してこれを達成しようとしました:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cvCell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
// Some code to initialize the cell
[cell addTarget:self action:@selector(showUserPopover:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)showUserPopover:(id)sender
{
//...
}
[cell addTarget:...]
ただし、次のエラーのある行で実行が中断されます。
-[UICollectionViewCell addTarget:action:forControlEvents:]: 認識されないセレクターがインスタンス 0x9c75e40 に送信されました