在UICollectionView中选择单元格不起作用

时间:2013-07-16 12:14:08

标签: uicollectionview

在我的主视图控制器中,我有一个 UICollectionView (使用IB创建)。而且:

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath: (NSIndexPath *)indexPath
{
 NSLog(@"Cell clicked....%d",[indexPath row]);
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView   cellForItemAtIndexPath:(NSIndexPath *)indexPath {

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];


ChildView *calendar = [[ChildView alloc] initWithDate:newDate];
calendar.delegate         = self;
[cell.contentView addSubview:calendar];

return cell;

}

如果我触摸到子视图的边界之外,我就会得到这个事件。如果我触摸子视图所在的单元格内部,didSelectCellAtRowIndex中不会捕获任何事件。 为什么呢?

1 个答案:

答案 0 :(得分:3)

集合视图在内部处理其触摸,因此视图上的任何触摸处理程序或手势识别器都将优先。