如何更新表格视图单元格? [英] How to update table view cell?
问题描述
我有一个带有一个大单元格和许多小单元格的 UITableView
.当我从服务器接收内容时,我使用函数 - (BOOL)performFetch:(NSError **)error
(NSFetchedResultsController
) 更新我的 UITableView
.我注意到我的大单元格在更新后重复了,第二个单元格没有重新加载.当我向下滚动并滚动到顶部表格时看起来不错.我该如何解决我的问题?
I have a UITableView
with one big cell and many small cells. When I receive content from server I update my UITableView
with function - (BOOL)performFetch:(NSError **)error
(NSFetchedResultsController
). I noticed that my big cell has dublicate after update and the second cell doesn't reload. When I scroll down and scroll to top table looks good.
How can I solve my problem?
推荐答案
"performFetch" 更新数据源但 tableview 本身没有更新.
"performFetch" updates the datasource but the tableview itself is not updated.
用于更新 tableview 使用
For updating the tableview use either
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)animation
或
- (void)reloadSections:(NSIndexSet *)sections
withRowAnimation:(UITableViewRowAnimation)animation
你可以选择你最喜欢的动画,例如 UITableViewRowAnimationMiddle 或者只是 UITableViewRowAnimationAutomatic
You can pick the animation you like best, for example UITableViewRowAnimationMiddle or just UITableViewRowAnimationAutomatic
出于性能原因,仅在必要时进行更新.
For performance reasons update only as much as necessary.
这篇关于如何更新表格视图单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!