我有一个表格视图,里面有一个集合视图。我想找出哪个集合视图单元格被点击,以及相应表视图单元格的 indexpath.row。(现在我能够从 didSelectRowAtIndexPath() 获取 indexpath.row 集合视图单元格但无法在那里找到存在哪个表格视图单元格对应的单元格。)
试试下面的代码,让我知道它是否适合你:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
CGRect frame = [collectionView convertRect:cell.frame toView:tblView];
NSIndexPath *tblIndexPath = [tblView indexPathForRowAtPoint:frame.origin];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句