你好:)这是我的代码:
myView.m是从xib加载的
- (void)loadData {
self.players = [model.dbManager.playersDbManager selectAllEntities];
[self.PlayersTableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.players.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomPopOverCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil) {
cell = [[CustomPopOverCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
}
// Configure the cell...
Player *p = (Player *)[self.players objectAtIndex:indexPath.row];
cell.fullName.text = p.firstName;
cell.number.text = (NSString *)p.jerseyNumber;
return cell;
}
myCustomCell.h:
@property (weak, nonatomic) IBOutlet UILabel *number;
@property (weak, nonatomic) IBOutlet UILabel *fullName;
myVC我加载xib:
self.popover = [[TaggingPopOver alloc] initWithFrame:CGRectMake(0, 0, contentContainer.frame.size.width, contentContainer.frame.size.height)];
[UIViewHelper showView:self.popover InCenterOfView:contentContainer];
self.popover.delegate = self;
[self.popover.PlayersTableView registerNib:[UINib nibWithNibName:@"Cell" bundle:nil] forCellReuseIdentifier:@"MyCell"];
[self.popover loadData];
This is the xib of customcell.
我尝试将fullname + number加载到我的自定义单元格中但出现错误
类不是键值fullName的键值编码
我尝试了一切但没有任何作用。有谁知道如何解决这个问题?
答案 0 :(得分:1)
您是否正在注册小区ID?
UINib* cellNib = [UINib nibWithNibName: self.cellID bundle: nil];
NSAssert(cellNib != nil, @"Cell nib %@ doesn’t exist", self.cellID);
[aTableView registerNib: cellNib forCellReuseIdentifier: self.cellID];
或在.xib文件中设置。
答案 1 :(得分:1)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomPopOverCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil) {
cell = [[CustomPopOverCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
}
// Configure the cell...
Player *p = (Player *)[self.players objectAtIndex:indexPath.row];
cell.fullName.text = [NSString stringWithFormat:@"%@",p.firstName];
cell.number.text = (NSString *)p.jerseyNumber;
return cell;
}
答案 2 :(得分:0)
对我来说,这原来是.xib文件中的一个对象(使用旧名称)引用了已重命名的控制类中的IBOutlet属性。
即我已经在控制器中重命名了IBOutlet属性,但无法更新.xib文件中的连接。