每个人都在写关于删除部分的文章。好吧,我似乎无法添加一个。
目前,我正在尝试这样(失败并出现 NSInternalInconsistencyException):
UITableView *tv = (UITableView *) self.tableView;
if ([tv numberOfSections] == 1)
{
[tv beginUpdates];
[tv insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop];
NSLog(@"Inserted.. Brace for impact.");
[tv endUpdates];
}
NSLog(@"Section count after update: %d", [tv numberOfSections]); // Never reached
如果我是正确的,插入一个索引为 0 的部分应该将它放在顶部,将所有其他部分向下撞,对吗?好吧,如果我在 insertSections 之后写出 numberOfSections,节数似乎没有变化。
有什么想法吗?
约翰
最佳答案
是的,谢谢你们。
经过一番折腾,我终于成功了。这是您的建议的结合。从未插入新数据,而且我不必增加插入的第一项的行数,而只需增加第二项。
关于iphone - 帮助在 TableView 中插入一个新部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/697683/