Wes*_*rra 1 uitableview ios swift
当我尝试在 iOS 13 上运行我的应用程序时,出现此错误,旧版本运行正常。
'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.'
Run Code Online (Sandbox Code Playgroud)
我认为这就是导致异常的原因
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)
}
}
Run Code Online (Sandbox Code Playgroud)
当我将变量行设置为一个数字时,它会毫无例外地加载,我认为 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()
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1622 次 |
| 最近记录: |