xcode “加载了“XXX”笔尖,但未设置视图插座。” - 再次
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17409839/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"loaded the "XXX" nib but the view outlet was not set." - again
提问by eggfish
Firstly I have inspected all of the other questions on this topic: the answers provided seem to be:
首先,我检查了有关该主题的所有其他问题:提供的答案似乎是:
- make sure you set the file's owner to your custom view controller class (which I have done)
- make sure you have a referencing outlet from the view to the file's owner (which I have)
- 确保您将文件的所有者设置为您的自定义视图控制器类(我已经完成了)
- 确保你有一个从视图到文件所有者的引用出口(我有)
My code is compiled to a static library, and I export the .a file and xib file. My example app that uses it includes the xib in its bundle ("copy bundle resources" in build phase)
我的代码被编译成一个静态库,然后我导出 .a 文件和 xib 文件。我使用它的示例应用程序在其包中包含了 xib(构建阶段的“复制包资源”)
In my library code I have a function in a separate UIViewContoller subclass to create the view controller from the nib:
在我的库代码中,我在单独的 UIViewContoller 子类中有一个函数来从笔尖创建视图控制器:
- (void) presentCustomController
{
self.vCtrl = [[CustomController alloc] initWithNibName:@"CustomController" bundle:nil];
...
}
When I run the example app, I inspect the _view member of self.vCtrl, and it is 0x0000, and of course this is what causes the exception in the posting title. My understanding was that the view to which that member points was 'auto generated' from the xib file, and it's children were the controls that I have put in it (buttons etc). What part of my understanding has fallen down? Is the problem related to the fact that it is in a static library? Thanks for any help.
当我运行示例应用程序时,我检查了self.vCtrl 的_view 成员,它是0x0000,当然这就是导致帖子标题异常的原因。我的理解是该成员指向的视图是从 xib 文件“自动生成”的,它的子项是我放入其中的控件(按钮等)。我的哪一部分理解下降了?问题是否与它位于静态库中的事实有关?谢谢你的帮助。
回答by JustAnotherCoder
If you are 100% that you connected your View to the File's Owner then I suggest you do the following:
如果您 100% 将视图连接到文件所有者,那么我建议您执行以下操作:
- Clean the project (
cmd+shift+K
) or Clean Build Folder if you prefer (cmd+shift+alt+K
) - Quit Xcode
- Restart Xcode
cmd+shift+K
如果您愿意,请清理项目 ( ) 或清理构建文件夹 (cmd+shift+alt+K
)- 退出 Xcode
- 重启Xcode
That should fix it hopefully.
那应该有希望解决它。
回答by Robert
Do you have multiple targets?
你有多个目标吗?
- make sure you set the file's owner to your custom view controller class (which I have done)
- 确保您将文件的所有者设置为您的自定义视图控制器类(我已经完成了)
I have come across a similar issue where I thought that I was setting the file's owner's custom class, however, IB was not actually setting it. Open the XIB as its raw xml and search for the custom class name.
我遇到了一个类似的问题,我认为我正在设置文件所有者的自定义类,但是,IB 实际上并没有设置它。打开 XIB 作为其原始 xml 并搜索自定义类名称。
For me it was because the .m of the view controller was not included for my specific target. To fix this check all the boxes in the target membership pane.
对我来说,这是因为我的特定目标不包含视图控制器的 .m。要解决此问题,请选中目标成员资格窗格中的所有框。