本文介绍了'UITableView'无法从其数据源获取单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了Xcode,此后我的数据库出现问题。
代码:

I updated Xcode and since then I'v problems with my dataBase.code:

override func numberOfSections(in tableView: UITableView) -> Int {
    // return the number of sections
    return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    // return the number of rows
    return leadItems.count
}

func cellForRow(at indexPath: IndexPath) -> UITableViewCell?
{
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! LeadsTableViewCell

    // Configure the cell...
    cell.user_name_label.text = leadItems[indexPath.row].user_name
    cell.school_name_label.text = leadItems[indexPath.row].school_name

    return cell
}

错误我得到的是:


推荐答案

您的cellForRow方法名称不正确。

Your method name for cellForRow is not correct.

替换此行

func cellForRow(at indexPath: IndexPath) -> UITableViewCell?
{

with

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

这篇关于'UITableView'无法从其数据源获取单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:46