collectionView:didSelectItemAtIndexPath:没有被调用

时间:2014-05-15 20:37:28

标签: uitableview uicollectionview uicollectionviewcell uicollectionviewdelegate

我有UITableview。其中一个UITableViewCell'sUICollectionview,其实例名称为" amenityView"。 UICollectionViewDelegateUICollectionViewDataSource设置在storyboard中,如下所示。调用以下方法并按预期填充数据。

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (UICollectionViewCell *)collectionView:(UICollectionView *)collection cellForItemAtIndexPath:(NSIndexPath *)indexPath

enter image description here

但是,当我选择UICollectionViewCell中包含的UICollectionView时,以下方法无法调用。我错过了什么?

-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
-(void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath

更新:  在此方法中返回YES collectionView:shouldSelectItemAtIndexPath:将调用以下两种方法。至少那是我缺少的东西。希望这会对一些身体有所帮助...... enter image description here

1 个答案:

答案 0 :(得分:1)

是否会调用表视图的didSelectRowAtIndexPath?如果是这样,表视图可能会拦截触摸而不会将它们传递到内部的集合视图。我从来没有完成你想要做的解决方案,但是集合视图在滚动视图中,并且可能不容易将触摸信息以有意义的方式传递到集合视图,因此您可能需要禁用点击表格视图单元格以使集合视图响应触摸。