- beginUpdates和endUpdates時配合起來使用的,標記了一個TableView的動畫模塊,代表動畫的開始和刪除,可以嵌套使用。一般在UITableView執行:刪除行,插入行,刪除分組,插入分組時使用,用來協調UITableView的動畫效果。
如果我們的UITableView是分組的時候,我們如果刪除某個分組的最后一條記錄時,相應的分組也將被刪除。所以,必須保證UITableView的分組,和cell同時被刪除。所以,就需要使用beginUpdates方法和endUpdates方法,將要做的刪除操作“包”起來。
2.一般使用在下列方法中
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
插入指定的行, 在執行該方法時,會對數據源進行訪問(分組數據和行數據),并更新可見行。所以,在調用該方法前,應該先更新數據源.
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
插入分組到制定位置,插入一個特定的分組。如果,指定的位置上已經存在了分組,那么原來的分組向后移動一個位置。
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation ;
刪除制定位置的分組,刪除一個制定位置的分組,其后面的分組向前移動一個位置。
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
移動分組,移動原來的分組從一個位置移動到一個新的位置。如果,新位置上若存在某個分組,那這某個分組將會向上(下)移動到臨近一個位置。該方法,沒有動畫參數。會直接移動。并且一次只能移動一個分組。