简体   繁体   English

'NSInternalInconsistencyExceptionException'原因:将表视图单元出队时,“无法在捆绑包中装载NIB”

[英]'NSInternalInconsistencyException' reason: 'Could not load NIB in bundle' when dequeuing tableview cell

I have no clue why I am getting this error and I have tried looking at other answers, but could not find a solution. 我不知道为什么会收到此错误,并且我尝试查看其他答案,但找不到解决方案。

The code in question: 有问题的代码:

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()
}

When tableView.dequeueReusableCell is called I get the error. 调用tableView.dequeueReusableCell时出现错误。 I have also made sure the identifier for the cell is set to "messageTableViewCell" 我还确保将单元格的标识符设置为“ messageTableViewCell”

Please make sure you have created a nib/xib file named as MessageTableViewCell , then register the nib file MessageTableViewCell , 请确保已创建一个名为MessageTableViewCellnib/xib文件,然后注册该nib文件MessageTableViewCell

let nib = UINib(nibName: "MessageTableViewCell", bundle: nil)
tableView.register(nib, forCellReuseIdentifier: "messageTableViewCell")

When you're initializing UINib , as nibName parameter you have to pass name of the file 初始化UINib ,必须将文件名作为nibName参数传递

在此处输入图片说明

UINib(nibName: "TableViewCell", bundle: nil)

so in your case I suppose your file is named same as your class MessagesTableViewCell 所以在您的情况下,我想您的文件的名称与您的类MessagesTableViewCell相同

messagesTableView?.register(UINib(nibName: "MessagesTableViewCell", bundle: nil), forCellReuseIdentifier: "messageTableViewCell")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'NSInternalInconsistencyException',原因:'无法在包中加载 NIB: - 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: NSInternalInconsistencyException',原因:'无法在包中加载 NIB:'NSBundle - NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle “ NSInternalInconsistencyException”,原因:“无法在捆绑包中加载NIB:...”,名称为 - 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: …' with name NSInternalInconsistencyException,原因:无法在bundle中加载NIB - NSInternalInconsistencyException, reason: Could not load NIB in bundle “ NSInternalInconsistencyException”,原因:“无法在捆绑包中加载NIB - 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle NSInternalInconsistencyException',原因:“无法在捆绑包中加载NIB-但它在那里,有点 - NSInternalInconsistencyException', reason: 'Could not load NIB in bundle - but it's there, sort of 应用因NSInternalInconsistencyException而崩溃,原因:“无法在捆绑包中加载NIB” - App crashes with NSInternalInconsistencyException', reason: 'Could not load NIB in bundle' NSInternalInconsistencyExceptionException:无法在捆绑包中加载NIB - NSInternalInconsistencyException: Could not load NIB in bundle NSInternalInconsistencyException-无法在捆绑包中加载NIB - NSInternalInconsistencyException - Could not load NIB in bundle 'NSInternalInconsistencyException',原因:'无法在捆绑软件中加载NIB:'Xcode中的NSBundle - 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle in Xcode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM