UITableViewRowAnimation as a block (instead of a row) animation

Is there anyway to make a UITableViewRowAnimation animate at the same time?

Such as, If I'm adding 4 rows to a TableView, animate the block of 4 rows rather than animating both row individually?

Snippet, tutorial for custom animation etc are welcome !

Answers


There are several ways as described in the docs:

Batch Insertion, Deletion, and Reloading of Rows and Sections

The UITableView class allows you to insert, delete, and reload a group of rows or sections at one time, animating the operations simultaneously in specified ways. The eight methods shown in Listing 7-7 pertain to batch insertion and deletion. Note that you can call these insertion and deletion methods outside of an animation block (as you do in the data source method tableView:commitEditingStyle:forRowAtIndexPath: as discussed in “Inserting and Deleting Rows in Editing Mode”).

Listing 7-7 Batch insertion and deletion methods

- (void)beginUpdates;
- (void)endUpdates;

- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation;
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation;
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

Need Your Help

Python and C++ code comparison

c++ python

I have the following python code

Mix CATextLayer and CAScrollLayer

iphone objective-c ios catextlayer quartz-core

I need a scrollable CATextLayer to display a NSAttributedString.

create unlimited ul li tag from fetch Array (for list)

php html-lists

I'm going to make a unlimited list use li and ul tags from my Array results of PDO(fetched)