UICollectionView inside TableViewCell not called

后端 未结 3 2040
轻奢々
轻奢々 2020-12-11 12:12

I have a UITableView contains one horizontal scroll UICollectionView in every cell like this

override func tableView(_ tableView: UITableView, cellForRowAt i         


        
相关标签:
3条回答
  • 2020-12-11 12:18

    This happens because your collection view instances are reused with cells. Only 4 instances are being created and reused.

    You can write your collectionview logic in your custom tableview cell and make custom cell as delegate and datasource of collectionview.

    0 讨论(0)
  • 2020-12-11 12:25

    Write collection view code on cell class. And give collectionview delegate to cell because cell is super class of collection view. Check this screen shot

    0 讨论(0)
  • 2020-12-11 12:39

    Not sure , whether this can Resolve your issue or not , but having consuming so much time finally i found the answer why CollectionView delgate method not gets called when it is embed inside TableView :

    we basically use these two :

    • UICollectionViewDataSource

    • UICollectionViewDelegate

    but forget to conform this : UICollectionViewDelegateFlowLayout

    After conforming this (UICollectionViewDelegateFlowLayout) did solve my issue .

    Hope it will solve other issue too. Feel free to comment and share your feedback. Thanks.

    0 讨论(0)
提交回复
热议问题