国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

關于cell局部刷新

2019-11-09 15:54:50
字體:
來源:轉載
供稿:網友

所謂NSIndexPath,主要用來標識cell在列表中的坐標位置,其有兩個屬性:section、row,section是用來標識cell處于第幾個section中,row是用來說明cell在該section中的第幾行。

兩種tableview. collectionview局部刷新方式

1. 刷新特定行row:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2];

  [_mainCollectionView reloadItemsAtIndexPaths:@[indexPath]];

2. 刷新特定分區section:
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];

 NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:3];

[_mainCollectionView reloadSections:indexSet];

傳入參數就是要刷新的cell所在的indexPath組成的數組。 
但,reloadItemsAtIndexPath默認會有一個動畫的過程,cell內容更新的瞬間會出現原內容與新內容重疊的情況。那么使用如下方式取消該動畫即可:

[UIView performWithoutAnimation:^{    [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];}];UITableView

UITableView的reloadSections方法也有同樣的情況:

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];而使用reloadData進行全部cell的更新,則沒有這個默認的動畫過程。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 静海县| 武邑县| 三原县| 富平县| 囊谦县| 大余县| 罗甸县| 长葛市| 兰州市| 泌阳县| 南通市| 六安市| 蓬溪县| 新干县| 曲阜市| 望谟县| 庆阳市| 化隆| 大埔区| 江孜县| 枣庄市| 黄山市| 长泰县| 长治县| 璧山县| 同仁县| 凯里市| 建水县| 多伦县| 宿州市| 武义县| 宜州市| 陕西省| 涟水县| 凌海市| 游戏| 宁阳县| 蒙自县| 林西县| 西林县| 抚顺县|