Vote count:
0
I can't get out of this, I have a UICollectionView with custom cell and every cell has a X button to delete it from the list, I pass to the button.tag the IndexPath.item and on the delete function i've implemented the following method:
- (void)DeleteProductFromArray:(UIButton *)button {
NSLog(@"item: %d",button.tag);
TagHelpConverted = [NSNumber numberWithInt:button.tag];
TagHelp = button.tag;
if(DeletedCells.count == 0)
{
[DeletedCells addObject:TagHelpConverted];
}
else
{
for(int i = 0; i < DeletedCells.count; i++)
{
if([TagHelpConverted compare:DeletedCells[i]] == NSOrderedDescending)
{
TagHelp--;
NSLog(@"ho diminuito il tag di 1");
}
}
[DeletedCells addObject:TagHelpConverted];
}
NSLog(@"valore tagHelp:%d", TagHelp);
[_feedItems removeObjectAtIndex:TagHelp];
[self.customCollectionView deleteItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:TagHelp inSection:0]]];
[self.customCollectionView reloadData];
}
The problem is that when scrolling the UICollectionView calls the - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
and my NSMutableArray that stores which button has already been clicked has "old values" that compared to the new ones assigned by this method makes the app delete random items inside the UICollectionView. I searched on the Internet for help about deleting UICollectionView cells but I found almost anything, I'm struggling very hard on this one but I can't find a way to get out, please if anyone has a solution help me
Need To delete cell from UICollectionView
Aucun commentaire:
Enregistrer un commentaire