Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 未显示TableView单元格中的图像_Swift_Uitableview - Fatal编程技术网

Swift 未显示TableView单元格中的图像

Swift 未显示TableView单元格中的图像,swift,uitableview,Swift,Uitableview,我有一个新的观点。TableView应显示图像和标签。我在情节提要和函数cellforrowatinexpath中设置了标识符。我为牢房的出口写了一节课。但是图像和标签没有显示…你能帮我吗? 细胞被创建了,我用浅灰色的背景色测试过 这是我的班级宣言: class TableViewController: UITableViewController { private let categories: [String] = ["Alle", "Apéritif", "Digestif", "Lon

我有一个新的观点。TableView应显示图像和标签。我在情节提要和函数cellforrowatinexpath中设置了标识符。我为牢房的出口写了一节课。但是图像和标签没有显示…你能帮我吗? 细胞被创建了,我用浅灰色的背景色测试过

这是我的班级宣言:

class TableViewController: UITableViewController {

private let categories: [String] = ["Alle", "Apéritif", "Digestif", "Long Drinks", "Tageskarte", "Favoriten", "Suche"]
private let images: [String] = ["Alle.jpeg", "americano.jpg", "brandy alexander.jpg", "bellini.jpg", "Tageskarte.jpg", "Favoriten.jpg", "suche.jpg"]

override func viewDidLoad() {
    super.viewDidLoad()

    navigationItem.title = "Cocktails"
    self.tableView.rowHeight = 100.0
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return categories.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! TableViewCell

    cell.labelStartpage.text = categories[indexPath.row]
    cell.imageViewStartpage.image = UIImage(named: images[indexPath.row])
    cell.backgroundColor = UIColor.lightGrayColor()

    return cell
}

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}
}

这就是出口等级:

class TableViewCell: UITableViewCell {

@IBOutlet weak var imageViewStartpage: UIImageView!
@IBOutlet weak var labelStartpage: UILabel!
}

已设置标识符
类也被设置为在表视图控制器中添加数据源和委托,或使用拖放绑定它。
它解决了您的问题。

您是否将数据源和委托添加到self?我不想“看到图像”。如果需要代码方面的帮助,请显示代码。复制并粘贴到这里。我添加了代码。Datasource和delegate是通过拖放设置的。我通过拖放设置Datasource和delegate,并对其进行了编码,但没有任何更改