私のUICollectionViewCellにはストーリーボードのボタンがあり、ボタンの数の背景イメージをドキュメントディレクトリから動的に設定することができます。そのコントローラを再度ロードすると、問題は依然として存在します。どのようにしてこの問題を解決できますか?マイCollectionViewControllerで再利用可能なUICollectionViewCellはリフレッシュしません
:私のカスタムcollectionViewセルに
- (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;
}
:
@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
wtはセクションと行のデータソースですか? – kaushal
plistファイルからデータを取得しています – Nuibb