UITableView + Core Animation

点点圈 提交于 2019-12-08 09:43:34

问题


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:


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



来源:https://stackoverflow.com/questions/12202221/uitableview-core-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!