繁体   English   中英

如何重新加载tableviewcell内的collectionview

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

我在tableViewCell中有一个collectionView

例如: 例 credit: 如何使用StoryBoard在UITableViewCell中快速构建一个collectionView

我想在更新信息时重新加载collectionView。

我在collectionView的cellForItemAtIndexPath中放置了一个print来测试它是否被调用但是它没有被调用。 如何让collectionView重新加载?

我发现了怎么样! 在我的tableViewCell类中,我只需要将collectionView链接为一个插座,所以在我的tableViewCell的cellForRowAtIndexPath我只需要调用cell.collectionView.reloadData()

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

tableview单元格中的第1个创建此函数:

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

然后从中调用它

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

    cell.collectionReloadData()

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM