【发布时间】:2016-11-06 16:07:35
【问题描述】:
我有一个UITableView,我用来自 JSON 字符串的数据填充它。
看看pastebin中的代码。
那时:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.beginUpdates()
self.tableView.reloadRowsAtIndexPaths(
[indexPath],
withRowAnimation: .Fade)
self.tableView.endUpdates()
})
它失败了。
我收到以下消息:
2016-11-06 16:32:06.579471 SO-33975355[4872:1389586] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 7 from section 0 which only contains 0 rows before the update'
如果我删除reloadRowsAtIndexPaths,它可以工作,但我不会更新行,除非您滚动或旋转设备。我当然希望它直接更新。
我想这与它的速度快有关吗?但是自从我修改了this from the example后,我完全一无所知。 (该示例不适用于 JSON,但使用来自维基百科的 url)
如果有人可以提供帮助,我会很高兴。
【问题讨论】:
标签: ios json swift uitableview tableview