Swift UIImageView未在设备上显示

时间:2018-03-08 17:05:45

标签: swift uiimageview

我正在使用以下代码在textFieldDidEndEditing中显示UIImageView:

let indexPath = IndexPath(row: 0, section: 0)
let cell = tableViewBodydata.cellForRow(at: indexPath) as! tvcell_Logbook
cell.imageViewArrow.isHidden = false
cell.imageViewArrow.image = UIImage(named: "same.png")

该代码在iPhone X Simulator上运行良好。但如果我在我的iPhone X设备上测试它,则不会显示imageView。该函数被正确调用,我对其进行了调整,但没有任何反应。我重新安装了应用程序几次,并重新启动设备但没有任何改变。请有人帮帮我吗?

修改1

我在cellForRow中使用此代码:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    var cell: tvcell_Logbook!

    if indexPath.row == 0 {

        cell = tableView.dequeueReusableCell(withIdentifier: "CellWeight", for: indexPath) as! tvcell_Logbook
        cell.imageViewArrow.isHidden = false
        cell.imageViewArrow.image = UIImage(named: "same.png")
    }

    ...

    return cell }

这个代码在textFieldDidEndEditing中:

func textFieldDidEndEditing(_ textField: UITextField) {

let indexPath = IndexPath(row: 0, section: 0)
let cell = tableViewBodydata.cellForRow(at: indexPath) as! tvcell_Logbook
cell.imageViewArrow.isHidden = false
cell.imageViewArrow.image = UIImage(named: "same.png") }                

1 个答案:

答案 0 :(得分:0)

如果你的文件名是Same.png:

UIImage(named: "Same.png")

你的图片如何在文件系统中命名?