国产探花免费观看_亚洲丰满少妇自慰呻吟_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的更新,則沒有這個默認的動畫過程。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 崇义县| 恩平市| 晋州市| 丹阳市| 北辰区| 六枝特区| 嘉兴市| 东港市| 苍溪县| 闻喜县| 长垣县| 乌苏市| 饶阳县| 巢湖市| 尉犁县| 北安市| 定陶县| 枣阳市| 龙门县| 和平区| 德庆县| 鄂托克旗| 石城县| 区。| 吉安市| 嘉义市| 栾城县| 克东县| 周口市| 望谟县| 汉中市| 和林格尔县| 商南县| 汝南县| 铜梁县| 威远县| 克什克腾旗| 云南省| 建水县| 琼中| 牡丹江市|