database - “UITableView”无法从其数据源获取单元格

标签 database swift xcode swift3

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

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
}

我得到的错误是:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView (; layer = ; contentOffset: {0, -64}; contentSize: {375, 65802}>) failed to obtain a cell from its dataSource ()

最佳答案

您的 cellForRow 方法名称不正确。

替换这一行

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

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

关于database - “UITableView”无法从其数据源获取单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39581800/

相关文章:

database - 在数据库列中存储分隔列表真的那么糟糕吗?

sql - MySQL REGEXP 怎么写?

ios - macOS 上的 SwiftUI,如何使整行可点击?

ios - 如何在 Swift 中使图像与其旁边的文本具有相同的高度?

iphone - Objective C - UIWebview 只加载网页的特定部分?

SQL数据库查询基本题

mysql - 数据库设计——主键命名约定

c++ - 编译我的第一个 C++ 程序时遇到问题

ios - 在返回导航中重置 View Controller

c++ - 为什么我的空数组不为空?