Collection View in Table does not load right away in swift 3

I am adding one table view to the Home View Controller.
Inside the table view, I add a Collection View.
The image inside the collection launches the application for the first time. Then go to other links and return to the house, but the image in the collection view does not appear immediately until it scrolls a second time.
By pulling the image several times, the image appears.
In " Collection.swift ",
In ViewDidLoad () ,

DispatchQueue.main.async { self.tableView.reloadData() } 

I also add to viewWillLayoutSubviews ()

 override func viewWillLayoutSubviews() { debugPrint("viewWillLayoutSubviews") DispatchQueue.main.async(execute: {() -> Void in self.tableView.reloadData() self.tableView.layoutIfNeeded() }) } 

and I also reload the collection view

  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 } 



In the Table Table Cell Element ( 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() } 

How can I do to download and show right away in swift 3? Can anybody help me?

0
uitableview uicollectionview
Jun 14 '17 at 9:56 on
source share

No one has answered this question yet.

See similar questions:

one hundred
UICollectionView inside UITableViewCell - dynamic height?
0
UITableViewCell image is not displayed until selected

or similar:

61
How to detect a tableView cell affected or by clicking in quick
21
Expand and collapse table cells
2
TableView does not display text with JSON data from an API call
one
AwakeFromNib method gets called twice by UITableViewCell
0
TableView for various viewControllers using Segues
0
frame.origin Change the error when viewing a table cell
0
after adding header cells are not displayed
0
How to fix cell.contentView.addSubview swift error?
0
Update or reload UITableView after completion of uninstall action in verbose view
0
Fast vertical UICollectionView inside UITableView



All Articles