在我的主视图控制器中,我有一个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
. 为什么?