首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自定义UITableViewCell NSUnknownKeyException

问自定义UITableViewCell NSUnknownKeyException
EN

Stack Overflow用户
提问于 2012-03-24 14:16:26
回答 3查看 3.5K关注 0票数 6
代码语言:javascript
复制
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *TodoListTableIdentifier = @"TodoListTableIdentifier";
    TodoTableViewCellController *cell = (TodoTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:TodoListTableIdentifier];
    if ( cell == nil ) 
    {
        NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil];
        cell=[nib objectAtIndex:0];
        [cell setSelectionStyle:UITableViewCellSelectionStyleGray];  
    }
    Todo *todo = [self.allTodoArray objectAtIndex:[indexPath row]];


    cell.titleLabel.text = todo.fileTitle;
    cell.money.text = [NSString stringWithFormat:@"Monei:%f",todo.amount];
    cell.name.text = todo.realName;
    cell.date.text = todo.operateTime;

    return cell;
 }

跑步时:

代码语言:javascript
复制
 NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil];

还有一个例外:*终止应用程序是由于未登录的异常'NSUnknownKeyException',原因:‘setValue:forUndefinedKey::这个类不符合键日期的键值编码。’

我不知道为什么会发生,所以请帮助我,谢谢你提前!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-03-24 14:26:43

此错误意味着您已将某些内容连接到nib中名为date的出口,但该出口不存在。你在哪里申报日期?

票数 18
EN

Stack Overflow用户

发布于 2015-03-05 22:34:33

UITableViewCell.

  • Set

  • 将文件所有者的Custom Class设置为单元格的

  • ,将单元格的Custom Class设置为自定义表,查看单元格类,在myCustomCell.h.

中查看myCustomCell.h.中的UIlabel

票数 3
EN

Stack Overflow用户

发布于 2012-03-24 14:25:01

连接TododTableViewController XIB中的所有出口(特别是视图出口),然后再次运行。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9852441

复制
相关文章

相似问题

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