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

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

關(guān)于cell局部刷新

2019-11-09 17:09:06
字體:
供稿:網(wǎng)友

所謂NSIndexPath,主要用來標(biāo)識cell在列表中的坐標(biāo)位置,其有兩個屬性:section、row,section是用來標(biāo)識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. 刷新特定分區(qū)section:
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];

 NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:3];

[_mainCollectionView reloadSections:indexSet];

傳入?yún)?shù)就是要刷新的cell所在的indexPath組成的數(shù)組。 
但,reloadItemsAtIndexPath默認(rèn)會有一個動畫的過程,cell內(nèi)容更新的瞬間會出現(xiàn)原內(nèi)容與新內(nèi)容重疊的情況。那么使用如下方式取消該動畫即可:

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

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

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];而使用reloadData進(jìn)行全部cell的更新,則沒有這個默認(rèn)的動畫過程。

下一篇:博客搬家

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 和林格尔县| 永顺县| 达孜县| 湖口县| 江西省| 油尖旺区| 景洪市| 巴彦淖尔市| 长沙市| 抚顺县| 章丘市| 斗六市| 夹江县| 晴隆县| 禹城市| 台北县| 竹溪县| 灵璧县| 鞍山市| 独山县| 时尚| 沅陵县| 左贡县| 丁青县| 马关县| 巨鹿县| 灵武市| 黄平县| 舟曲县| 宣恩县| 宜州市| 同江市| 双峰县| 雷山县| 石阡县| 宿迁市| 永善县| 布拖县| 基隆市| 景东| 五原县|