2015-10-29 53 views
0

所以我有一個自定義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 
+0

Zombie物體的配置文件,讓我們知道結果。 –

回答

0

我看到這個錯誤:

//名稱

cell.abilityNameLabel = self.championInfo[@"spells"][indexPath.row - 1][@"name"]; 

我覺得應該是:

// Name 
cell.abilityNameLabel.text = self.championInfo[@"spells"][indexPath.row - 1][@"name"]; 
+0

補給它。它是你閱讀某些內容的時刻之一,看看你是否犯了一個愚蠢的錯誤,但是你的大腦填補了錯誤,直到有人指出它爲止。 – Victor

相關問題