gpt4 book ai didi

objective-c - 带有自定义表格 View 单元格的无法识别的选择器

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:07 26 4
gpt4 key购买 nike

我有一个自定义的表格 View 单元格。但是当我想在我的 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;
}

有人可以帮忙吗?

亲切的问候。

最佳答案

尝试

if ((cell == nil) || (![cell isKindOfClass: KlassementCell.class])) {

队列中返回的单元格可能不是 KlassementCell。

关于objective-c - 带有自定义表格 View 单元格的无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12782588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com