'UITableView'无法从其数据源获取单元格 [英] 'UITableView' failed to obtain a cell from its dataSource
本文介绍了'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
}
错误我得到的是:
由于未捕获的异常 NSInternalInconsistencyException而终止应用程序,原因: UITableView(; layer =; contentOffset:{0, -64}; contentSize:{375,65802}>)无法从其dataSource()获取单元格
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方法名称不正确。
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'无法从其数据源获取单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文