首先确保你的tableview在正常刷新的时候也没问题,因为插入Section只是多了个动画效果
主要的为
[tableView beginUpdates];
和
[tableView endUpdates];
确保这个刷新不会在循环里面,就是插入未结束的时候不能重新进行插入
insertSections:<#(nonnull NSIndexSet *)#> withRowAnimation:<#(UITableViewRowAnimation)#>]第一个参数就是插入的section值,第二个是动画效果
NSindexSet的初始化可以为[NSIndexSet indexSetWithIndex:1];
既插入到section1当中,如果section1当前有东西的话,那么下移。
插入动作在begin和end之间进行。