【发布时间】:2011-08-24 15:00:53
【问题描述】:
我有一个很好的错误,特别是在慢速设备中。 我有一个类似于 App Store 应用程序中的 UITableView jusk,底部有一个加载更多按钮。 当它被按下时,我从服务器加载新信息,设置数组,然后重新加载表格视图。在该信息中也是表格行中显示的每个对象的图像的 url,所以当我们得到它时,我们开始下载图像。加载图像时,我重新加载对象的行。
[self.searchResultsTableView reloadRowsAtIndexPaths: [NSArray arrayWithObject: path] withRowAnimation: UITableViewRowAnimationNone];
问题出现在重新加载行时,因为图像已下载,并且整个表正在这样做,因为用户按下了加载更多按钮并获得了更多信息。然后我得到这个错误:
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (140) must be equal to the number of rows contained in that section before the update (125), plus or minus the number of rows inserted or deleted from that section (1 inserted, 1 deleted).
这是完全不稳定的,在更新新图像行时表格被放大了。 我的问题是:如何锁定它,以便在重新加载整个表之前不重新加载该行?它会像 table.isReloading 这样的东西。我尝试使用布尔锁,并在主线程中执行这两个操作,但它没有工作...... 非常感谢。
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview crash