Mon UICollectionViewCell a un bouton story-board et réglage de l'image de fond du nombre de boutons dynamiquement à partir du répertoire de documents qui crée des problèmes comme des boutons image de fond n'a pas rafraîchissant, ils tiennent vieille image même quand je rejette la contrôleur et charger à nouveau ce contrôleur, le problème existe toujours. Comment peut-on résoudre ce problème?réutilisable UICollectionViewCell ne rafraîchissant
Mon CollectionViewController:
- (NSString *)getBackgroundImage:(NSIndexPath *)indexPath {
NSArray *indexes = [self.allColors[indexPath.section] objectForKey:@"indexes"];
return [NSString stringWithFormat:@"%@/%@/%@/combimeter_button/combimeter_%ld_%@@2x.png", [self.documentDirectory getDocumentsDirectory], _selectedCar, _selectedCar, (long)[indexes[indexPath.row] integerValue], [self getColorKey:indexPath.section]];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CustomCollectionViewCell *cell = (CustomCollectionViewCell *) [collectionView dequeueReusableCellWithReuseIdentifier:@"CustomCell" forIndexPath:indexPath];
cell.layer.borderWidth = 2.0f;
cell.layer.borderColor = [[self getBackgroundColor:indexPath.section] CGColor];
[cell.cellButton setBackgroundImage:[UIImage imageNamed:[self getBackgroundImage:indexPath]] forState:UIControlStateNormal];
[cell.cellButton addTarget:self action:@selector(combimeterButtonDidSelected:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
Dans mon habitude CollectionView Cell:
@interface CustomCollectionViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIButton *cellButton;
@end
@implementation CustomCollectionViewCell
-(void)prepareForReuse {
NSLog(@"Is it possible to clear here ? but this method didn't call in my code");
}
@end
poids est votre source de données pour la section et les lignes? – kaushal
Je reçois les données du fichier plist – Nuibb