首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自定义UITableViewCell出错

自定义UITableViewCell出错
EN

Stack Overflow用户
提问于 2011-03-18 01:57:20
回答 6查看 4K关注 0票数 4

我得到了这个错误:

代码语言:javascript
复制
 *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x5a37750> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key destination.'

代码如下:

代码语言:javascript
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"ReservationCell";

    ReservationCell *cell = (ReservationCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ReservationCell" owner:nil options:nil];
        for (id currentObject in topLevelObjects){
            if ([currentObject isKindOfClass:[UITableViewCell class]]){
                cell = (ReservationCell *) currentObject;
                break;
            }
        }
    }


    //cell.origin.text = [[data objectAtIndex:indexPath.row] origin];
    //cell.destination.text = [[data objectAtIndex:indexPath.row] destination]; 
    //cell.time_range.text = [[data objectAtIndex:indexPath.row] time_range]; 

    return cell;
}

这里是ReservationCell.h

代码语言:javascript
复制
@interface ReservationCell : UITableViewCell {
    UILabel * origin;
    UILabel * destination;
    UILabel * time_range;
}

@property (nonatomic, retain) IBOutlet UILabel * origin;
@property (nonatomic, retain) IBOutlet UILabel * destination;
@property (nonatomic, retain) IBOutlet UILabel * time_range;

@end

下面是我如何把它连接起来的:

EN

Stack Overflow用户

发布于 2012-05-14 19:07:44

对于像我这样已经接触到这个主题但不能找到解决方案的人,这里是这个问题的快速解决方案:

在界面构建器中,当您应该从单元格视图中链接IBOutlets时,您却链接了来自文件所有者的文件。这就是你得到这些错误的原因。

祝你好运!

票数 10
EN
查看全部 6 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5343172

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档