कुछ घटनाओं पर,सभी वस्तुओं को कैसे हटाएं और UICollectionView में नए आइटम कैसे जोड़ें?
मैं एक uicollectionview में सभी कक्षों को निकालें, और नई कोशिकाओं जोड़ें। (जो एक नेटवर्क कॉल की वजह से से भरी हुई होगी) को
मैं deleteItemsAtIndexPaths उपयोग करने की कोशिश करना चाहते हैं। पुनः लोड करेंक्शन, हटाएंक्शन/सम्मिलित करेंक्शन।
उनमें से प्रत्येक ने मेरे ऐप को क्रैश कर दिया।
नीचे मेरा कोड है।
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];
उपयोग '[collectionView reloadData]' –