0

Here I am trying to insert the Sections 1 and Section 3 as soon as address get filled in Section 2. Initially they must be hidden or still not inserted in table view. I get success in inserting the Section 3 but unable to insert Section 2. Here is my piece of code after address get filled in Section 2.

-(void)viewWillAppear:(BOOL)animated {

  [self.reviewOrderList insertSections:[NSIndexSet indexSetWithIndex:3] 
  withRowAnimation:UITableViewRowAnimationBottom];
  [self.reviewOrderList reloadData];

 }

enter image description here

4

1 回答 1

1

您可以创建一个实例NSMutableIndexSet并添加要添加的部分的索引。然后你可以在-[UITableView insertSections:withRowAnimation:]. 您不需要立即调用-[UITableView reloadData]:插入方法会自动执行显示新部分所需的操作。您甚至可以通过-[UITableView beginUpdates]在进行更改之前调用并通过调用-[UITableView endUpdates].

有关更多信息,请查看UITableView 类参考

于 2013-06-17T09:22:12.287 回答