簡體   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