gpt4 book ai didi

ios - UITableView heightForRowAt 总是崩溃

转载 作者:可可西里 更新时间:2023-11-01 00:39:38 26 4
gpt4 key购买 nike

我正在研究 UI 以使其与设计相同,我使用 heightForRowAt 将第一部分的单元格高度设置为 96px,我尝试了:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return 96.0
default:
return 56.0
}
}

但它崩溃了,我到处搜索,但问题一直没有解决

所以我尝试进行测试:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 56.0
}

但它也崩溃了。

Xcode 只是给我 Thread 1:signal SIGABRT 错误,我找不到解决方案。为什么这会发生在我身上?

+++ 错误发生时的控制台消息

screenshot of console message

最佳答案

您的崩溃错误与您提到的自定义高度无关。在您获取索引路径处的行的单元格的方法中,您试图将同一索引路径的两个单元格出列...

你的代码中一定有这样的东西......

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ident", for: indexPath)
let cell2 = tableView.dequeueReusableCell(withIdentifier: "ident", for: indexPath)
}

iOS 正在崩溃,让您知道每个索引路径只能出列一个单元格...

关于ios - UITableView heightForRowAt 总是崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46785761/

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