Home > Back-end >  UITableView didSelect issue with nested UiCollectionView
UITableView didSelect issue with nested UiCollectionView

Time:11-18

I have a tableView with cells that contain UiCollectionView. My didSelect tableView's delegate isn't called when I touch the cell on the collectionView. I think it's my collectionView that get the touch instead. Do you have any elegant solution to keep the scroll enabled on my collectionView but disable the selection and pass it to the tableview ? Thanks

CodePudding user response:

I don't know the details of your code, but the below actions may solve your problem.

If your not using any UICollectionViewDelegate protocol functionslike didSelect , shouldSelectItemAt ext. just remove collectionview.delegate = self in your cell class. This will help to trigger tableview's didSelect instead of trigger collectionView didSelect

CodePudding user response:

Maybe you would like to try allowsSelection property of UICollectionView. If you set this property false, your collection view cells are not selected any more.

And I think tableView didSelect can capture user interaction. If UITableView still can not capture didSelect, you can give delegate to collectionView and fire it once it's tapped by adding a tap gesture onto UICollectionView.

  • Related