【发布时间】:2015-09-11 13:11:48
【问题描述】:
我的 UITableViewCell 给出了一个 -[UITableViewCell nameTeam]: unrecognized selector sent to instance。
我创建了一个带有 UITableViewCell 和 UILabel 的 PlayerStatsTableViewCell.xib。将自定义类设置为“PlayerStatsTableViewCell”,并将其表视图单元格标识符设置为“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;
}
PlayerStatsTableViewCell.xib 显示自定义类和标识符
错误信息
来自 Storyboard 的 PlayerStatsTableViewController
【问题讨论】:
-
不需要写"[tableView registerNib:[UINib nibWithNibName:@"PlayerStatsTableViewCell" bundle:nil] forCellReuseIdentifier:@"playerStats"];"
标签: uitableview xib unrecognized-selector