Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 自定义UITableViewCell和IBOutlet出错_Objective C_Ios_Uitableview_Xib - Fatal编程技术网

Objective c 自定义UITableViewCell和IBOutlet出错

Objective c 自定义UITableViewCell和IBOutlet出错,objective-c,ios,uitableview,xib,Objective C,Ios,Uitableview,Xib,我首先说,我不确定我所做的是不是最好的方法。 我有以下场景:一个动态分组的TableView,有两个组,第一个组有一个静态单元格,第二个组有一个由数组填充的动态单元格。 第二组很好,第一组不行 第一个组只有一个自定义单元格,我使用以下代码加载该单元格: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // ... if

我首先说,我不确定我所做的是不是最好的方法。 我有以下场景:一个动态分组的
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;
    }

    // ...
}
actordeailsheadercell.xib
文件有一个名为
actordeailsheadercell
的自定义类,该类扩展了
UITableViewCell
类。 如果我让一切都像这样(只是为了测试目的),一切正常,只要我在
actordeailsheadercell.h
文件中设置
IBOutlet
,我就会得到以下错误:

'NSUnknownKeyException', reason: '[<ActorDetailsViewController 0x7485a60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.'
'NSUnknownKeyException',原因:'[和,但这些答案似乎并不能解决我的问题。
我试图删除
.xib
和类,并从头重写它们,但那该死的错误总是存在


我最后说,同样的东西在其他
UITableViewController
中使用,而且它工作得很好!

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


我认为这是一个xcode错误…我不知道!无论如何谢谢你的错误声明ActorDetailsViewController没有响应所讨论的键,但是你说你试图在ActorDetailsHeaderCell上设置一个值。这个错误似乎表明你试图在错误的对象上设置一个值,也许?正如你在我的代码中看到的,我试图在
headerCell
上设置一个值,这是一个
ActorDetailsHeaderCell
对象,它不是一个
ActorDetailsViewController
。这件事让我很害怕!也许你的ActorDetailsHeaderCell.xib中有一个对象试图在文件所有者上设置一个值(在这种情况下,它是你的viewController),但viewController没有IBOutlet设置。如果您注释掉headerCell.actorName.text=self.actor.name;行,它是否有效?另外,您所说的“在ActorDetailsHeaderCell.h文件中设置IBOutlet后,我会出现此错误”是什么意思--您要添加什么出口?如果我注释掉那一行,它也不起作用。我的意思是,如果我没有将任何IBOutlet(1个UIImage和2个UILabel)从xib连接到类的标题,则不会出现错误消息!