所謂NSIndexPath,主要用來標(biāo)識cell在列表中的坐標(biāo)位置,其有兩個屬性:section、row,section是用來標(biāo)識cell處于第幾個section中,row是用來說明cell在該section中的第幾行。
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2];
[_mainCollectionView reloadItemsAtIndexPaths:@[indexPath]];
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]];}];UITableViewUITableView的reloadSections方法也有同樣的情況:
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];而使用reloadData進(jìn)行全部cell的更新,則沒有這個默認(rèn)的動畫過程。
新聞熱點(diǎn)
疑難解答