2015-06-25 2 views
0

My UITableViewCell предоставляет идентификатор - [UITableViewCell nameTeam]: непризнанный селектор, отправленный экземпляру.Подкласс UITableViewCell бросает непризнанный селектор, отправленный в экземпляр

Я создал PlayerStatsTableViewCell.xib с UITableViewCell и UILabel. Установите пользовательский класс для "PlayerStatsTableViewCell" и его Table View Cell идентификатор в "playerStats"

PlayerStatsTableViewCell.h

@interface PlayerStatsTableViewCell : UITableViewCell 
@property (weak, nonatomic) IBOutlet UILabel *nameTeam; 
@end 

PlayerStatsTableViewCell.m

@implementation PlayerStatsTableViewCell 
@synthesize nameTeam; 

- (void)awakeFromNib { 
    // Initialization code 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

В моей PlayerStatsTableViewController, cell.nameTeam является выброс ошибки

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    PlayerStatsTableViewCell *cell = (PlayerStatsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"playerStats"]; 
    [tableView registerNib:[UINib nibWithNibName:@"PlayerStatsTableViewCell" bundle:nil] forCellReuseIdentifier:@"playerStats"]; 

    cell.nameTeam.text = @"PLEASE"; 

    return cell; 
} 

PlayerStat sTableViewCell.xib показывая пользовательского класса и идентификатор

enter image description here enter image description here

Сообщение об ошибке enter image description here

PlayerStatsTableViewController из раскадровки enter image description here

+0

нет необходимости писать «[Tableview registerNib: [UINib nibWithNibName: пакет "PlayerStatsTableViewCell": nil] forCellReuseIdenti Фиер: @ "playerStats"];» –

ответ

0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    PlayerStatsTableViewCell *cell = (PlayerStatsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"playerStats"]; 
    if (cell == nil) { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PlayerStatsTableViewCell" owner:self options:nil]; 
      cell = (PlayerStatsTableViewCell *)[nib objectAtIndex:0]; 
    } 

    cell.nameTeam.text = @"PLEASE"; 

    return cell; 
}