用處:抖音首頁 上啦加載數(shù)據(jù) 和 下拉也加載數(shù)據(jù)的時候用的到下面的知識
倒敘插入數(shù)據(jù)到數(shù)組最前方
NSArray *modelArray = [self testModel];
// 倒敘插入數(shù)據(jù)到數(shù)組最前方
NSMutableIndexSet *indexes = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, modelArray.count)];
NSArray *reversedArray = [[modelArray reverseObjectEnumerator] allObjects];
[self.dataSouceArray insertObjects:reversedArray atIndexes:indexes];
倒敘添加數(shù)據(jù)到數(shù)組最后方
NSArray *modelArray = [self testModel];
// 倒敘添加數(shù)據(jù)到數(shù)組最后方
NSArray *reversedArray = [[modelArray reverseObjectEnumerator] allObjects];
[self.dataSouceArray addObjectsFromArray:reversedArray];
collectionView 滾動到可視區(qū)域
[self.backgroundView.collectionView reloadData];
[self.backgroundView.collectionView layoutIfNeeded];
[self.backgroundView.collectionView scrollRectToVisible:rect animated:NO];
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者