如何通过表视图中的数组在uiimageview中设置图像

问题描述 投票:0回答:1

var imgg = [“ wall-wallpaper-500x500.jpg”,“ wall-wallpaper-500x500.jpg”,“ wall-wallpaper-500x500.jpg”]........

func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath)-> UITableViewCell {卫队让userCell = tableView.dequeueReusableCell(withIdentifier:“ ViewTableViewCell”,for:indexPath)为? ViewTableViewCell else {致命错误()}

      if indexPath.section == 0{
                  userCell.thirdlbl.text = names[indexPath.row]
                  userCell.firstlbl.text = android[indexPath.row]
                  userCell.secondlbl.text = "ios"
        userCell.buttonLabel.text = "Hello"
        userCell.img.image = imgg[indexPath.row] // Cannot assign value of type 'String' to type 'UIImage?'

              }
arrays swift image uiimage tableview
1个回答
0
投票
userCell.img.image = UIImage(named: imgg[indexPath.row])
© www.soinside.com 2019 - 2024. All rights reserved.