[英]'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:
[英]'NSInternalInconsistencyException' reason: 'Could not load NIB in bundle' when dequeuing tableview cell
我不知道为什么会收到此错误,并且我尝试查看其他答案,但找不到解决方案。
有问题的代码:
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.