无法识别的选择我有一个自定义的tableview细胞。但是当我想在我的cellForRowAtIndexpath中调用这个单元格时,它会给出以下错误。定制的tableview细胞
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell lblPosition]: unrecognized selector sent to instance 0xa62a600'
我检查了100次,如果everthing正确连接并命名正确,但仍然没有发现什么是错的。这就是我在代码中所做的。
- (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;
}
任何人都可以帮忙吗?
亲切的问候。
,我应该把这个? – Steaphann
Oké这个工程,但你能说为什么这有助于?因为我在此错误 – Steaphann
搜索了几个小时我猜的iOS具有可重复使用的UICell(这不是一个KlassementCell)在队列中,并提供它,当你调用dequeueReusableCellWithIdentifier。但是,我不明白为什么它排在队列中。 – jptsetung