【发布时间】:2013-07-30 10:52:34
【问题描述】:
我想处理点击 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
【问题讨论】:
标签: objective-c cocoa-touch uicollectionview target-action