gpt4 book ai didi

ios - 'NSInternalInconsistencyException',原因 : 'Requested the number of rows for section (0) which is out of bounds.'

转载 作者:行者123 更新时间:2023-12-01 18:03:41 26 4
gpt4 key购买 nike

当我尝试在 iOS 13 上运行我的应用程序时出现此错误,旧版本运行良好。

'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.'

这就是我认为导致异常的原因
override func reloadData() {
super.reloadData()

let rows = self.numberOfRows(inSection: 0) // what I know is that this line is causing the exception
if (rows > 0) {
if placeholderStackView != nil {
self.placeholderStackView.removeFromSuperview()
}
} else {
setTableStatus(type: .empty)
}

}

当我将变量行设置为它无一异常(exception)地加载的数字时,我认为 UITableView SDK 的更新导致了它,我尝试在谷歌搜索一些见解,但没有成功。

最佳答案

检查 self.numberOfSections第一的。如果没有部分,则该部分中不能有行(超出范围)。

override func reloadData() {
super.reloadData()

guard 0 < self.numberOfSections && 0 < self.numberOfRows(inSection: 0) else {
setTableStatus(type: .empty)
return
}

if placeholderStackView != nil {
self.placeholderStackView.removeFromSuperview()
}
}

关于ios - 'NSInternalInconsistencyException',原因 : 'Requested the number of rows for section (0) which is out of bounds.' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61141561/

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