我有一个自定义的 tableview 单元格。但是当我想在我的 cellForRowAtIndexpath 中调用这个单元格时,它会给出以下错误。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell lblPosition]: unrecognized selector sent to instance 0xa62a600'
如果一切都正确连接并正确命名,我检查了 100 次,但仍然没有发现问题所在。这就是我在代码中所做的。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"KlassementCell";
KlassementCell *cell = (KlassementCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"KlassementCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
// ask NSFetchedResultsController for the NSMO at the row in question
Klassement *klassement = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Then configure the cell using it ...
NSString *pointDiff = [NSString stringWithFormat:@"%@", klassement.goalsDiff];
NSLog(@"position %@",klassement.position);
NSLog(@"name %@",klassement.name);
cell.lblPosition.text = klassement.position;
cell.lblName.text = klassement.name;
cell.lblgamesPlayed.text = klassement.gamesPlayed;
cell.lblGamesWon.text = klassement.gamesWon;
cell.lblGamesTied.text = klassement.gamesTied;
cell.lblGamesLost.text = klassement.gamesLost;
cell.lblGoalsPos.text = klassement.goalsPos;
cell.lblGoalsNeg.text = klassement.goalsNeg;
cell.lblGoalsDiff.text = pointDiff;
cell.lblPoints.text = klassement.points;
return cell;
}
有人可以帮忙吗?
亲切的问候。