Uitableview 表内的集合视图在swift 3中不会立即加载

Uitableview 表内的集合视图在swift 3中不会立即加载,uitableview,uicollectionview,imageview,swift3.2,Uitableview,Uicollectionview,Imageview,Swift3.2,我在主视图控制器中添加了一个表视图。在表视图中,我添加了集合视图 第一次运行应用程序时收集视图中的图像。然后,转到其他链接并返回主页,但在第二次滚动之前,集合视图中的图像不会立即显示 多次拖动视图后,将显示图像。 在“Collection.swift”中,在ViewDidLoad()中 DispatchQueue.main.async { self.tableView.reloadData() } 我还添加了视图willlayoutsubviews() override func vi

我在主视图控制器中添加了一个表视图。
在表视图中,我添加了集合视图
第一次运行应用程序时收集视图中的图像。然后,转到其他链接并返回主页,但在第二次滚动之前,集合视图中的图像不会立即显示
多次拖动视图后,将显示图像。
在“Collection.swift”中,
ViewDidLoad()中

DispatchQueue.main.async {
    self.tableView.reloadData()
}
我还添加了视图willlayoutsubviews()

override func viewWillLayoutSubviews() {

    debugPrint("viewWillLayoutSubviews")
    DispatchQueue.main.async(execute: {() -> Void in
        self.tableView.reloadData()
        self.tableView.layoutIfNeeded()
    })   
}
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let mainThemeList = mainHomeThemeTable[(indexPath as NSIndexPath).row]
    self.prefs.set(mainThemeList.main_associated_url, forKey: "associated_home_url")
    let cell = tableView.dequeueReusableCell(withIdentifier: "homecell") as! HomeCategoryRowCell

    DispatchQueue.main.async {
        cell.categoryTitle.text = mainThemeList.main_name
        cell.mainAssociatedURL.text = mainThemeList.main_associated_url
        cell.categoryTitle.font = UIFont.boldSystemFont(ofSize: 17.0)
        cell.collectionView.reloadData()

    }

    return cell
}
我还重新加载收藏视图

override func viewWillLayoutSubviews() {

    debugPrint("viewWillLayoutSubviews")
    DispatchQueue.main.async(execute: {() -> Void in
        self.tableView.reloadData()
        self.tableView.layoutIfNeeded()
    })   
}
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let mainThemeList = mainHomeThemeTable[(indexPath as NSIndexPath).row]
    self.prefs.set(mainThemeList.main_associated_url, forKey: "associated_home_url")
    let cell = tableView.dequeueReusableCell(withIdentifier: "homecell") as! HomeCategoryRowCell

    DispatchQueue.main.async {
        cell.categoryTitle.text = mainThemeList.main_name
        cell.mainAssociatedURL.text = mainThemeList.main_associated_url
        cell.categoryTitle.font = UIFont.boldSystemFont(ofSize: 17.0)
        cell.collectionView.reloadData()

    }

    return cell
}


表格视图单元格(CollectionCell.swift)文件中,

override func awakeFromNib() {
   self.collectionView.reloadData()
   self.collectionView.setNeedsLayout()
   self.collectionView.layoutIfNeeded() } 


override func layoutSubviews() {
    super.layoutSubviews()
     self.collectionView.reloadData()
     self.collectionView.setNeedsLayout()
     self.collectionView.layoutIfNeeded()


}

如何在swift 3中立即加载和显示?有人能帮我吗?

collectionView.reloadData()在表视图的自定义单元格中,可以很容易地用表视图重新加载如果不加载,请留下评论我会给你另一个建议,并将代码写入视图didAspect()Bro@BHAVIKPANCHAL,我在视图didAspect中添加tableView.reloadData()。现在,当应用程序运行时,图像立即显示。但是,当我转到其他页面并返回主页时,图像不显示,需要拉刷新。bro@BHAVIKPANCHAL,我更新了我的问题。兄弟,你能看一下吗?我想你可以这样解决