问题
I'm getting this error when I try to run my app on iOS 13, older versions was working fine.
'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.'
This is what I presume that is causing the exception
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)
}
}
when I set the variable row to a number it loads without exception, I presume that an update on UITableView SDK caused it, I've tried searching google for some insights, but no success on this.
回答1:
Check for self.numberOfSections
first. If there are no sections, then there can be no rows in that section (out of bounds).
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()
}
}
来源:https://stackoverflow.com/questions/61141561/nsinternalinconsistencyexception-reason-requested-the-number-of-rows-for-se