gpt4 book ai didi

ios - 使用 UItableView Swift 4 的自定义单元格时的 SIGBRT

转载 作者:行者123 更新时间:2023-11-30 11:58:30 25 4
gpt4 key购买 nike

不知道为什么我不断收到 SIGBRT。我已经被这个简单的错误困扰了很长时间,它开始变得烦人。有人知道如何解决这个问题吗?一切似乎都链接在一起,但当 TableView 尝试加载单元格时程序崩溃。注意:我没有使用该 ImageView 或灰色标签,这只是从以前的项目复制并粘贴的单元格。

.xib 用于自定义单元格:标识符为“customMessageCell”

enter image description here

使用自定义单元格的代码:

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: "customMessageCell" , for: indexPath) as! CustomMessage;
let gray = UIColor(red:0.94, green:0.94, blue:0.94, alpha:1.0)
let red = UIColor(red:1.00, green:0.22, blue:0.37, alpha:1.0)

let message = messages[indexPath.item]
if message.toId == user?.toId{
cell.messageBackground.backgroundColor = red
cell.messageBody.textColor = UIColor.white
}
else{
cell.messageBackground.backgroundColor = gray
}

cell.messageBody.text = message.text


return cell;
}

编辑这是确切的错误消息:libc++abi.dylib:因未捕获的 NSException 类型异常而终止

线程 1:信号 SIGABRT 在应用程序委托(delegate)的第 1 行崩溃。

最佳答案

将 CustomCell 类分配给界面构建器中的 uitableviewcell,并将单元格可重用标识符分配给该类。这可能是崩溃的主要原因,因为在您的情况下,tableview 无法解析具有可重用单元标识符“customMessageCell”的 uitableviewcell

关于ios - 使用 UItableView Swift 4 的自定义单元格时的 SIGBRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47517572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com