简体   繁体   English

如何重新加载tableviewcell内的collectionview

[英]how to reload a collectionview that is inside a tableviewcell

I have a collectionView inside a tableViewCell 我在tableViewCell中有一个collectionView

for example: 例如: 例 credit: How to use StoryBoard quick build a collectionView inside UITableViewCell credit: 如何使用StoryBoard在UITableViewCell中快速构建一个collectionView

I would like to reload the collectionView when I update information. 我想在更新信息时重新加载collectionView。

I have put a print in the collectionView's cellForItemAtIndexPath to test if it is being called but it isn't. 我在collectionView的cellForItemAtIndexPath中放置了一个print来测试它是否被调用但是它没有被调用。 How can I get the collectionView to reload? 如何让collectionView重新加载?

I found out how! 我发现了怎么样! In my tableViewCell class I just need to link the collectionView as an outlet so in my tableViewCell's cellForRowAtIndexPath I just needed to call cell.collectionView.reloadData() 在我的tableViewCell类中,我只需要将collectionView链接为一个插座,所以在我的tableViewCell的cellForRowAtIndexPath我只需要调用cell.collectionView.reloadData()

使用UITableView indexPath.row为集合视图创建标签,并使用标签创建UICollectionView的实例并重新加载!

1st on tableview cell create this function: tableview单元格中的第1个创建此函数:

func collectionReloadData(){
        DispatchQueue.main.async(execute: {
            self.collectionView.reloadData()
        })
    }

then call it from 然后从中调用它

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { ...

    cell.collectionReloadData()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift:如何以编程方式在 TableViewCell 中显示 CollectionView - Swift: How to display a CollectionView inside a TableViewCell Programmatically CollectionView与TableViewCell中的图像 - CollectionView with images inside a TableViewCell TableViewCell 内的 CollectionView - CollectionView inside TableViewCell 重新加载TableViewCell内的CollectionviewCell - Reload CollectionviewCell inside TableViewCell 使用包含CollectionView的自定义单元格重新加载单个TableViewCell - Reload single TableViewCell with Custom Cell that includes CollectionView Swift UITest在tableviewcell内找不到collectionview - Swift UITest Can not find collectionview inside of tableviewcell Self Sizing CollectionView 在 Self Sizing TableViewCell 内 - Self Sizing CollectionView inside a Self Sizing TableViewCell 当点击collectionView单元格内的按钮时,如何获取表格视图行并从位于tableViewCell内的collectionView推送到viewController - how to get table view row and push to viewController from collectionView that's inside a tableViewCell when tapped button inside collectionView cell 单击tableview header按钮时,如何将tableviewcell内的collectionview中的数据显示到另一个视图controller - How to display data from collectionview inside tableviewcell to another view controller when tableview header button is clicked 如何仅在 swift 中重新加载 tableViewCell? - How to reload tableViewCell only in swift?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM