Reputation: 5010
In the current version of Facebook app there's a cell at the top of the timeline view called "News Feed". It's the post filter feature. If you tap it, new cells at the bottom of that cell slides down and became visible. It's a pleasurable effect. Did you know how to implement something alike? In your opinion all happens inside the same UITableViewCell or what?
Upvotes: 3
Views: 611
Reputation: 9536
This is achievable using insertRowsAtIndexPaths:withRowAnimation
Bear in mind that your data source for the table needs to accommodate for the inserted rows, and so does your numberOfRowsInSection
method as well.
I think the appropriate animation effect to use here is UITableViewRowAnimationTop
so that the cells look like they're inserting from top to bottom.
In your example, once the user taps on the news feed cell, you would probably do:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects: [NSIndexPath indexPathForRow:1 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:3 inSection:0], nil] withRowAnimation:UITableViewRowAnimationBottom];
Your numberOfRowsInSection
method would return your original value + 3.
Your cellForRowAtIndexPath
method should have code to build the news cells which have just been added.
Upvotes: 2