我不知道为什么会收到此错误,我尝试查看其他答案,但找不到解决方案。
有问题的代码:
override func viewDidLoad() {
super.viewDidLoad()
messagesTableView?.register(UINib.init(nibName: "messageTableViewCell", bundle: nil), forCellReuseIdentifier: "messageTableViewCell")
messagesTableView.delegate = self;
messagesTableView.dataSource = self;
dataSrc.delegate = self
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "messageTableViewCell", for: indexPath) as? MessagesTableViewCell {
cell.configureWithItem(item: dataArray[indexPath.item])
return cell
}
return UITableViewCell()
}
调用 tableView.dequeueReusableCell 时出现错误。我还确保单元格的标识符设置为“messageTableViewCell”
最佳答案
请确保您已经创建了一个名为MessageTableViewCell
的nib/xib
文件,然后注册nib文件MessageTableViewCell
,
let nib = UINib(nibName: "MessageTableViewCell", bundle: nil)
tableView.register(nib, forCellReuseIdentifier: "messageTableViewCell")
关于ios - 'NSInternalInconsistencyException' 原因 : 'Could not load NIB in bundle' when dequeuing tableview cell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53936132/