0

我首先说我不确定我正在做的事情是否是最好的方法。我有以下场景:一个动态分组TableView有两个组,第一个有一个静态单元格,第二个有一个由数组填充的动态单元格。第二组工作正常,第一组不行!

第一组只有一个自定义单元格,我使用此代码加载:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // ...

    if (indexPath.section == kSectionHeader) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ActorDetailsHeaderCell" owner:self options:nil];
        ActorDetailsHeaderCell * headerCell = [topLevelObjects objectAtIndex:0];

        headerCell.image.image = [UIImage imageNamed:self.actor.image];
        headerCell.actorName.text = self.actor.name;
        headerCell.info.text = @"";

        return headerCell;
    }

    // ...
}

ActorDetailsHeaderCell.xib文件有一个名为ActorDetailsHeaderCell扩展类的自定义UITableViewCell类。如果我留下这样的一切(仅用于测试目的)一切正常,只要我设置一个文件IBOutletActorDetailsHeaderCell.h我就会收到这个错误:

'NSUnknownKeyException', reason: '[<ActorDetailsViewController 0x7485a60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.'

我在 Stackoverflow 上发现了这些问题:iPhone: "unrecognized selector sent to instance"自定义 UITableViewCell 错误,但这些答案似乎并不能解决我的问题。我试图删除.xib和类并从头开始重写它们,但那个该死的错误总是存在!

我最后说,同样的东西也用在了其他东西上UITableViewController,而且效果很好!

4

1 回答 1

0

我不知道为什么今天一切正常!我昨天晚上关闭了该项目,但出现了那个错误,今天早上该应用程序可以正常工作了!

我认为是一个 xcode 错误...我不知道!不管怎么说,还是要谢谢你

于 2012-11-06T09:01:38.847 回答