我更新了 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/