How to update table view cell?

ぃ、小莉子 提交于 2019-12-11 12:44:54

问题


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?


回答1:


"performFetch" updates the datasource but the tableview itself is not updated.

For updating the tableview use either

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths
              withRowAnimation:(UITableViewRowAnimation)animation

or

- (void)reloadSections:(NSIndexSet *)sections
      withRowAnimation:(UITableViewRowAnimation)animation

You can pick the animation you like best, for example UITableViewRowAnimationMiddle or just UITableViewRowAnimationAutomatic

For performance reasons update only as much as necessary.



来源:https://stackoverflow.com/questions/25929510/how-to-update-table-view-cell

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