Swift UITableViewController [处于保留状态]

问题描述 投票:-2回答:1

我从编程开始,我想制作一个表格,每个单元格中都有图像。我的问题是,直到我单击该单元格或将其从屏幕上滑出片刻,图像才会出现。

ios uiimageview uikit tableview
1个回答
0
投票

我为自定义单元格创建了一个类,但现在找到了解决方案:我忘记添加方法layoutSubviews(),现在图像立即显示。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = self.tableView.dequeueReusableCell(withIdentifier: "id") as! CustomCell
        cell.image = data[indexPath.row].image
        cell.text = data[indexPath.row].message
        cell.layoutSubviews()
        return cell
    }

无论如何都感谢您的帮助。

© www.soinside.com 2019 - 2024. All rights reserved.