collectionView:didSelectItemAtIndexPath:没有被调用

Loo*_*zie 7 uitableview uicollectionview uicollectionviewcell uicollectionviewdelegate

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

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (UICollectionViewCell *)collectionView:(UICollectionView *)collection cellForItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但是,当我选择UICollectionViewCell包含在中的包含时,下面的方法没有被调用UICollectionView.我错过了什么?

-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
-(void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

UPDATE:在此方法中返回YES collectionView:shouldSelectItemAtIndexPath:将调用以下两个方法.至少那是我所缺少的.希望这会对一些身体有所帮助...... 在此输入图像描述

BJ *_*ler 1

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