我在尝试将图像数组加载到 UITableView 时遇到问题,该 UITableView 具有另一个 View Controller 中的原型(prototype)单元格。
我似乎没有从 swift 3 error : Argument labels '(_:)' do not match any available overloads 得到答案因为我很新,无法从答案中得出解释。
我从以下位置收到标题中的错误:
let portraitsOfHeroes:[UIImage] = UIImage(named: "picture1", "picture2", "picture3")
尝试使用(portraitsOfHeroes)制作图像数组时:
import UIKit
class NewHeroVC: UIViewController, UITableViewDataSource {
let listOfHeroes:[String] = ["Name1", "Name2", "Name3"]
let portraitsOfHeroes:[UIImage] = UIImage(named: "picture1", "picture2", "picture3")
并通过 (cell.newHeroPortrait.image) 使用它们:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "heroCell", for: indexPath) as! NewHeroCell
cell.newHeroName.text = listOfHeroes[indexPath.row]
cell.newHeroPortrait.image = portraitsOfHeroes[indexPath.row]
return cell
}
它在我的阵列上返回错误的原因是什么?
最佳答案
我觉得你需要
let portraitsOfHeroes:[UIImage] = [UIImage(named: "picture1"), UIImage(named: "picture2"), UIImage(named: "picture3")
关于ios - 尝试将 UIImage 数组加载到 UITableView 时,Swift 3 错误 : "Argument labels ' (named:_:, _ :, )' do not match any available overloads",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44058641/