UICollection View inside Table Cell does not show images in Swift 3

后端 未结 1 904
长发绾君心
长发绾君心 2020-12-21 22:55

I put UICollectionView inside table cell in Home page. Each category row has their contents image.
But, my problem is that when I run the app, the images under second r

相关标签:
1条回答
  • 2020-12-21 23:13

    Edit controller like below, you are calling too many reloadData.

    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        self.tableView.layoutIfNeeded()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
    //getSearchWords()
        DispatchQueue.main.async {
            self.tableView.reloadData()
        }
        self.tableView.layoutIfNeeded()
    }
    
    override func viewDidLoad() {
            super.viewDidLoad()
    
        tableView.delegate = self
        tableView.dataSource = self
    }
    

    and add:

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                tableView .deselectRow(at: indexPath, animated: false)  
    }
    
    0 讨论(0)
提交回复
热议问题