Tuesday, March 6, 2012

Insertion of rows in UITableView

Ok, In previous post, I gave a sample code of how to delete rows from UITableView using

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

Now in insertion everything is basically same, you have to following same steps,
1. Get the array of indexPath at which you want to insert your cells.
2. Update your dataArray (Insert the relevant items in dataArray at respective indices)
3. Insertion code block

[myTableView beginUpdates];
[myTableView insertRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationAutomatic];
[myTableView endUpdates];

No comments:

Post a Comment