I am currently building a UITableView that reads an array and displays it on a TableView. I am continually adding to the array I would like to have a button on the view that once is clicked it updates the UITableView.
How do I implement a reload of the UITableView from the new array I just built?
If you are adding and removing items one to a few at a time you will likely want to implement the animated table view methods for insertion and deletion.
When you add or remove an item from the table view you will prepare by calling
[tableView beginUpdates]make your array modifications and then call[tableView endUpdates]Between the begin and end update calls you will perform the actually deletion/insertion.
For deletion you should use
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];Notice
UITableViewRowAnimationBottomyou will want to play around with this to get the best animation depending on the position of the element. Also iOS5 has a enum value something likeUITableViewRowAnimationAutomaticand it will use the best option.For insertion you should use
insertRowsAtIndexPaths:withRowAnimation:the same way I show above with delete.For more info check out the section with these methods listed in the UITableView class reference