xcode Interface Builder Storyboard 编译失败?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20386784/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:23:21  来源:igfitidea点击:

Interface Builder Storyboard Compilation Failed?

iosxcodeuistoryboard

提问by wufoo

New to Xcode here -- Is there a way to get more detail out of Xcode when it runs into a compile time error? The only message I get when I try to build my application is "Interface Builder Storyboard Compilation Failed". I have no idea what file it's having a problem with.

这里是 Xcode 的新手——当它遇到编译时错误时,有没有办法从 Xcode 中获取更多细节?当我尝试构建我的应用程序时,我收到的唯一消息是“Interface Builder Storyboard Compilation Failed”。我不知道是哪个文件有问题。

Seriously?

严重地?

Nothing additional turns up under the "Build" item in the Log Navigator either.

日志导航器中的“构建”项下也没有其他内容。

enter image description here

在此处输入图片说明

回答by digitalHound

Thanks to wufoo I figured mine out.

感谢 wufoo 我想通了。

I have a tableview that has five static cells. The cells have an assortment of UIImageViews, UITextFields, etc. I had created IBOutlets in the main UITableViewController .h file and connected directly to the static cells UITextfields in the storyboard. You can't do that.

我有一个包含五个静态单元格的 tableview。这些单元格有各种各样的 UIImageViews、UITextFields 等。我在主 UITableViewController .h 文件中创建了 IBOutlets,并直接连接到故事板中的静态单元格 UITextfields。你不能那样做。

Once I removed those connections it compiled fine for me.

一旦我删除了这些连接,它就可以很好地为我编译。

It appears you have to connect UIWidgets (textfields, labels, imageviews, etc) in a statically created cell directly to IBOutlets in that cells .h file (NOT, as I did, to IBOutlets in the tableview .h file).

看来您必须将静态创建的单元格中的 UIWidget(文本字段、标签、图像视图等)直接连接到该单元格 .h 文件中的 IBOutlets(不像我那样,连接到 tableview .h 文件中的 IBOutlets)。

---- UPDATE ----
Ok, so my initial post was not entirely accurate. It appears you CAN connect IBOutlets from subclasses of UITableViewCell directly to the main UITableViewController .h file. You just have to make sure that you set the Table View Content field to "Static Cells". I missed that step.

---- 更新----
好的,所以我最初的帖子并不完全准确。看来您可以将 IBOutlets 从 UITableViewCell 的子类直接连接到主 UITableViewController .h 文件。您只需确保将表视图内容字段设置为“静态单元格”。我错过了那一步。

Here is an image to illustrate: ScreenshotSelect your storyboard, in the detail pane on the left, ensure that your "Table View" is selected. In the pane on the right select your attributes inspector panel and change from "Dynamic Prototypes" to "Static Cells". Setup your static cells by dragging and dropping your components onto the storyboard, then if you want to link from your components directly to IBOutlet properties on your main ViewController .h file you can.

这是一张图片来说明: 截屏选择您的故事板,在左侧的详细信息窗格中,确保选择了您的“表格视图”。在右侧的窗格中,选择您的属性检查器面板并将“动态原型”更改为“静态单元”。通过将组件拖放到情节提要上来设置静态单元格,然后如果您想从组件直接链接到主 ViewController .h 文件上的 IBOutlet 属性,则可以。

I discovered the issue I was having was that I set up static cells in storyboard, and then tried to recreate them again dynamically in the delegate method cellForRowAtIndexPath:. That does not work very well. If you use static cells you do not need to use any of the cell setup delegate methods.

我发现我遇到的问题是我在故事板中设置了静态单元格,然后尝试在委托方法 cellForRowAtIndexPath: 中再次动态地重新创建它们。那效果不佳。如果您使用静态单元格,则不需要使用任何单元格设置委托方法。

Here is some excellent reading that also helped me out: Apple TableView Programming Guide

以下是一些对我也有帮助的优秀读物: Apple TableView 编程指南

回答by wufoo

For what it's worth, the problem seems to be related to two IBOutletobjects declared in my .m file. One was referencing a UISliderand the other a UILabel. I removed the references and then declared them as class variables instead. In viewDidLoadI hooked them up using [self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET]. Looks like the same solution as mentioned by f.perdition in the link above.

就其价值而言,问题似乎与IBOutlet我的 .m 文件中声明的两个对象有关。一个是引用 a UISlider,另一个是 a UILabel。我删除了引用,然后将它们声明为类变量。在viewDidLoad我使用[self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET]. 看起来与上面链接中 f.perdition 提到的解决方案相同。

回答by Nitin Alabur

For me, it was two identical storyboards in the project that lead to this error popping up frequently.

对我来说,是项目中的两个相同的故事板导致这个错误频繁出现。

I created a storyboard X, added a view controller Y in it. Then I refactored a view controller Z to storyboard X. Xcode asked if I want to replace the existing storyboard X and I selected Yes.

我创建了一个故事板 X,在其中添加了一个视图控制器 Y。然后我将视图控制器 Z 重构为故事板 X。Xcode 询问我是否要替换现有的故事板 X,我选择是。

Its only after a few hrs I noticed that there are two references for the storyboard in file / project navigator (left pane). Removed one of the referneces and the issue hasn't shown up after that.

几个小时后,我注意到文件/项目导航器(左窗格)中有两个故事板参考。删除了其中一个引用,此后问题未出现。