-
-
Save anka/ad11b4017a8967b741bd to your computer and use it in GitHub Desktop.
iOS simple table view row animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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