UITableView + Core Animation

2019-06-13 16:26发布

I would like to build up a table view section into my iOS app just like the Facebook style (with many information in every row, images and buttons, ..).

I also want to include Core Animation effects on every row, like fade out the cell, or customize the graphic interface.

Do you recommend me to use the UITableView class or something else more 'customizable'?

1条回答
成全新的幸福
2楼-- · 2019-06-13 16:52

You should use the regular UITableView, but custom UITableViewCells. UITableView's support fading and other kind of animations for adding/removing/reloading cells

NSMutableArray *affectedRows = [NSMutableArray array];
[affectedRows addObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[affectedRows addObject:[NSIndexPath indexPathForRow:1 inSection:0]];

// use whatever corresponds
[self.tableView deleteRowsAtIndexPaths:affectedRows withRowAnimation:UITableViewRowAnimationLeft];

[self.tableView insertRowsAtIndexPaths:affectedRows withRowAnimation:UITableViewRowAnimationLeft];

[self.tableView reloadRowsAtIndexPaths:affectedRows withRowAnimation:UITableViewRowAnimationLeft];

Be careful when using these methods, because the numberOfRowsInSection: function gets called again, and if the new result doesn't match the new number of rows, your app will crash

IE: you have 5 rows, and delete 2, your method must then return 3

查看更多
登录 后发表回答