自从开始使用iOS 6(以及iOS 7)编译我的应用程序之后,我开始看到这个消息。我知道UITableView在iOS 6中管理单元格的方式不同,但我没有必要修改我的代码让它继续工作。但我担心这个消息可能指向一些潜在问题,我还没有看到。有人能解释一下吗?
看起来我的问题是在我试图更新UI时触发的,而这部分代码是从Web调用的回调中调用的。我通过强制在主线程上进行UI更新来解决了这个问题。我使用了类似于以下的代码。
void runOnMainQueueWithoutDeadlocking(void (^block)(void)){
if ([NSThread isMainThread])
{
block();
}
else
{
dispatch_sync(dispatch_get_main_queue(), block);
}
}
我在后台网页调用的成功块中按如下方式调用它。
runOnMainQueueWithoutDeadlocking(^{
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
});
又是另一个条件...
当我不想要一个头部时,我返回 nil
导致了这种情况。
解决方法:
func tableView(tableView: UITableView,
titleForHeaderInSection section: Int) -> String? {
return ""
}
NSIndexPath *reloadRow = [NSIndexPath indexPathForRow:1 inSection:2];
[self._mainTableView reloadRowsAtIndexPaths:@[reloadWebViewRow]
withRowAnimation:UITableViewRowAnimationFade];
但是不小心,我打错了
NSIndexPath *reloadRow = [NSIndexPath indexPathForItem:1 inSection:2];
indexPathForItem
创建的(错误的),另一个是使用indexPathForRow
创建的(正确的)。
所有这些都导致了tableView非常奇怪的行为和标题中的错误消息。好的,我刚刚花了一整天的时间来尝试解决这个问题,希望这个替代性的解释能够节省其他人的时间。
我有一个表格视图,在加载时有时会出现这个消息。原来是由于在视图加载时触发了Core Data对象的KVO通知。(在观察到更改时,我的控制器尝试在相关的表格视图上调用reloadData。通过在视图完成加载之前不观察对象来修复此问题(以前我是在分配访问器后开始观察对象)
TLDR:检查一下你是否正在尝试从除主线程以外的其他地方重新加载数据。