UITableView +核心动画 [英] UITableView + Core Animation
问题描述
我想像 Facebook 样式一样在我的iOS应用程序中建立一个表格视图部分(每行中都有很多信息,图像和按钮,.. )。
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, ..).
我还想在每行上包含 Core Animation效果,例如淡出单元格或自定义图形界面。
I also want to include Core Animation effects on every row, like fade out the cell, or customize the graphic interface.
您是否建议我使用UITableView类或其他更具可定制性的东西?
Do you recommend me to use the UITableView class or something else more 'customizable'?
推荐答案
您应使用常规的 UITableView
,但应使用自定义的 UITableViewCells
。
UITableView
支持的淡入淡出和其他类型的动画,用于添加/删除/重新加载单元格
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];
使用这些方法时要小心,因为numberOfRowsInSection:函数会再次被调用,如果新结果与新的行数不匹配,您的应用将崩溃
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:您有5行,并删除2,然后您的方法必须返回3
IE: you have 5 rows, and delete 2, your method must then return 3
这篇关于UITableView +核心动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!