首页 > 解决方案 > Prevent Single Row from Refreshing in UITableView

问题描述

I have a custom section header in my UITableView that contains A UICollectionView of some avatar images. The data is sourced once and cached for the images (images change so infrequently that it doesn't warrant real time updates).

I was hoping to make it so this header never redraws again even if the UITableView refresh is called. The reasoning for this is every time you take action, it causes the images to flicker as they're being redrawn from their default anonymous silhouette to the actual image of the person. The images are cached, but it doesn't matter because

I assume this is not possible by design - a UITableView will destroy everything and reload it all over again every time the refresh is called, correct?

I just wish I could hook into the refresh and preserve the section header, and reload the rows only.

Thanks for any ideas/guidance, I know this is a little uncommon but I don't want to move the header out into its own view because i'm using a UITableViewController directly, and it would be a real pain to have to embed it in a containerview and all that.

标签: iosswiftuitableviewuitableviewsectionheader

解决方案


是的,即使您缓存了图像并通过本地或其他方式设置,加载也需要时间。如果您使用延迟加载,它将是飞溅(肯定:))。所以,唯一可能的事情是,你必须在刷新后更新你的 tableView 是使用tableView.beginUpdatesand tableView.endUpdates。刷新后根据数据输入一些添加单元格或删除单元格


推荐阅读