[英]iOS xib file IBOutlet not recognized - (class not key-value coding compliant)
I am running XCode 7.1 and running on device(iOS 9) - (not simulator). 我正在运行XCode 7.1并在设备(iOS 9)-(不是模拟器)上运行。 I am loading up a nib file by name as such:
我正在按名称加载笔尖文件,如下所示:
MyDetailsViewController *myDetailsVC = [MyDetailsViewController initWithNibNamed:@"MyDetails" withNotificationCenter:notificationCenter];
this is simply just a class method that i have set up that loads up the xib via the mainBundle. 这只是我设置的一个类方法,它通过mainBundle加载了xib。 The xib file is just a
UIView
with a tableview inside of it everything seems to be hooked up properly. xib文件只是一个内部带有表视图的
UIView
,似乎所有内容都已正确连接。 However, when loading the nib( viewWillAppear
, viewDidLoad
etc hasn't executed yet) from the bundle I get the error: 但是,当从包中加载笔尖(
viewWillAppear
, viewDidLoad
等尚未执行)时,出现错误:
NSUnknownKeyException, reason: '[MyDetailsViewController setValue:forUndefinedKey:]:This class is not key value coding-compliant for the key tableView'
NSUnknownKeyException,原因:“ [MyDetailsViewController setValue:forUndefinedKey:]:此类与键tableView的键值编码不兼容”
I know that I am not getting back some generic view controller because it spells out very clearly what view controller we are talking about. 我知道我不会再找一些通用的视图控制器了,因为它可以很清楚地说明我们在说什么视图控制器。 The File Owner seems to be hooked up properly and its Custom Class is set to
MyDetailsViewController
. 文件所有者似乎已正确连接,其自定义类设置为
MyDetailsViewController
。 Even when I hover over the IBOutlet 'circle' in code the tableview highlights as well as when i hover over the menu when checking the outlets. 即使当我将鼠标悬停在代码中的IBOutlet“圆圈”上时,表格视图也会突出显示,并且当我在检查插座时将鼠标悬停在菜单上时。
Something that may be totally unrelated is the internal error message in the xib file, it may or may not be related to my problem and i've never seen it before. xib文件中的内部错误消息可能是完全不相关的,它可能与我的问题有关,也可能与我的问题无关,我以前从未见过。 The beginning of the log file that you get from that error is:
从该错误中获取的日志文件的开头是:
Can anyone help me determine what is going on here? 谁能帮我确定这是怎么回事? I would appreciate it.
我会很感激。
here are a few more screenshots: 这里还有一些截图:
Before init
you should call alloc
first: 在
init
之前,您应该先调用alloc
:
// MyDetailsViewController *myDetailsVC = [MyDetailsViewController initWithNibNamed:@"MyDetails" withNotificationCenter:notificationCenter];
MyDetailsViewController *myDetailsVC = [[MyDetailsViewController alloc] initWithNibNamed:@"MyDetails" withNotificationCenter:notificationCenter];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.