Skip to content

Instantly share code, notes, and snippets.

@anka
Created January 4, 2015 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anka/ad11b4017a8967b741bd to your computer and use it in GitHub Desktop.
Save anka/ad11b4017a8967b741bd to your computer and use it in GitHub Desktop.
iOS simple table view row animation
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _data.count;
}
</pre>
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