ios - 尝试将 UIImage 数组加载到 UITableView 时,Swift 3 错误 : "Argument labels ' (named:_:, _ :, )' do not match any available overloads"

标签 ios arrays swift uitableview xcode8

我在尝试将图像数组加载到 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/

相关文章:

ios - 如何使用 Swift 3 生成 RSA 公钥和私钥?

c# - 使用 StreamWriter 的文件中的 NULL 符号

ios - UserNotification 中显示的图像的长宽比与图像在数据库中的存储方式相关

c# - 在随机数组中搜索特定值

arrays - 如何根据数值属性对对象数组进行正确排序

ios - 如何最好地优化 NSLayoutConstraint?

ios - Swift 4 - 使用 FBSDKGraphRequest 查询 facebook

ios - 创建带有文本和十字符号的动态标签

php - 在关联数组中搜索和替换

修改数组时的 Javascript 通知