所以我有一個自定義UITableViewCell與3 UILabels。其中每個文本都設置爲label.text = @"something";
。但是,當我滾動過去(讓我們說單元格0),然後向後滾動到它,該應用程序崩潰與-[__NSCFString setText:]: unrecognized selector sent to instance
與我設置文本突出顯示爲紅色的行。所有其他單元(使用相同的可重用單元)都沒有填充該標籤。在UITableViewCell子類中,我有用strong
設置的屬性。UILabel無法識別的選擇器發送到實例
類具有的UITableView:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ChampionDetailSpellCell *cell = [tableView dequeueReusableCellWithIdentifier:@"championAbilityCell" forIndexPath:indexPath];
// Performance
cell.layer.rasterizationScale = [[UIScreen mainScreen] scale];
cell.layer.shouldRasterize = YES;
// Design
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView = nil;
// Reset
cell.abilityIcon.image = nil;
cell.abilityNameLabel.text = nil;
cell.abilityCost.text = nil;
cell.abilityRange.text = nil;
cell.abilityDescription.text = nil;
// Content
if (indexPath.row == 0) {
// Passive
// Icon
[DDragon getChampionPassiveIcon:self.championInfo[@"passive"][@"image"][@"full"] :^(NSURL *championPassiveIconURL) {
[cell.abilityIcon setImageWithURL:championPassiveIconURL];
}];
// Name
cell.abilityNameLabel.text = self.championInfo[@"passive"][@"name"];
// Tooltip
cell.abilityDescription.text = self.championInfo[@"passive"][@"sanitizedDescription"];
} else {
// Ability
// Image
[DDragon getChampionAbilityIcon:self.championInfo[@"spells"][indexPath.row - 1][@"image"][@"full"] :^(NSURL *championAbilityIconURL) {
[cell.abilityIcon setImageWithURL:championAbilityIconURL];
}];
// Name
cell.abilityNameLabel = self.championInfo[@"spells"][indexPath.row - 1][@"name"];
// Cost
cell.abilityCost.text = [NSString stringWithFormat:@"%@ %@", self.championInfo[@"spells"][indexPath.row - 1][@"costBurn"], self.championInfo[@"spells"][indexPath.row - 1][@"costType"]];
// Range
cell.abilityRange.text = self.championInfo[@"spells"][indexPath.row - 1][@"rangeBurn"];
// Tooltip
cell.abilityDescription.text = self.championInfo[@"spells"][indexPath.row - 1][@"sanitizedTooltip"];
}
return cell;
}
的UITableViewCell子類
@interface ChampionDetailSpellCell : UITableViewCell
@property (strong) IBOutlet UIImageView *abilityIcon;
@property (strong) IBOutlet UILabel *abilityNameLabel;
@property (strong) IBOutlet UILabel *abilityCost;
@property (strong) IBOutlet UILabel *abilityRange;
@property (strong) IBOutlet UITextView *abilityDescription;
@end
Zombie物體的配置文件,讓我們知道結果。 –