这里,我尝试在 Section 2
中填写地址后立即插入 Sections 1
和 Section 3
。最初它们必须隐藏或仍然不插入表 View 中。我成功插入了 Section 3
,但无法插入 Section 2
。这是我在第 2 部分
中填写地址后的代码。
-(void)viewWillAppear:(BOOL)animated {
[self.reviewOrderList insertSections:[NSIndexSet indexSetWithIndex:3]
withRowAnimation:UITableViewRowAnimationBottom];
[self.reviewOrderList reloadData];
}
最佳答案
您可以创建 NSMutableIndexSet
的实例并添加要添加的部分的索引。然后你可以在-[UITableView insertSections:withRowAnimation:]
中传递该indexSet 。您不需要调用-[UITableView reloadData]
之后:插入方法会自动执行显示新部分所需的操作。您甚至可以通过调用 -[UITableView beginUpdates]
批量进行多个更改并立即为它们设置动画。在进行更改并通过调用 -[UITableView endUpdates]
完成更改之前.
有关更多信息,请查看 UITableView Class Reference .
关于ios - 一次插入两个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17143988/