W pewnych zdarzeń,Jak usunąć wszystkie elementy i dodać nowe elementy do UICollectionView?
Chciałbym usunąć wszystkie komórki w uicollectionview i dodawanie nowych komórek. (Która zostanie wypełniona w wyniku połączenia sieciowego)
Próbowałem za pomocą deleteItemsAtIndexPaths. reloadSections, deleteSections/insertSections.
Każdy z nich zniszczył moją aplikację.
Poniżej znajduje się mój kod.
NSMutableArray* indexPathArray = [[NSMutableArray alloc] init];
for(int i=0; i < [self.jsonAlbumImageArray count]; ++i)
{
NSIndexPath* newPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPathArray addObject: newPath];
}
[self.jsonAlbumImageArray removeAllObjects];
if(indexPathArray.count > 0)
{
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:indexPathArray];
}
completion: nil];
}
// NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)];
// NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:0];
// [self.collectionView reloadSections:indexSet];
[self get_IMAGE_LIST_FROM_SERVER];
użycie '[CollectionView reloadData]' –