我想处理点击 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