Create a gist now

Instantly share code, notes, and snippets.

iOS simple table view row animation
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _data.count;
However the interesting part is the next method, where we are going to initiate the view update.
<pre class="lang:objc decode:true ">- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
// Update the data model
[_data removeObjectAtIndex:indexPath.row];
// Animate the removal of the row
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[tableView endUpdates];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment