简体   繁体   English

Interface Builder Storyboard 编译失败?

[英]Interface Builder Storyboard Compilation Failed?

New to Xcode here -- Is there a way to get more detail out of Xcode when it runs into a compile time error? Xcode 新手 - 有没有办法在遇到编译时错误时从 Xcode 中获取更多详细信息? The only message I get when I try to build my application is "Interface Builder Storyboard Compilation Failed".我在尝试构建应用程序时收到的唯一消息是“Interface Builder Storyboard Compilation Failed”。 I have no idea what file it's having a problem with.我不知道是哪个文件有问题。

认真的?

Nothing additional turns up under the "Build" item in the Log Navigator either.日志导航器中的“构建”项下也没有其他内容。

在此处输入图片说明

Thanks to wufoo I figured mine out.感谢 wufoo 我想通了。

I have a tableview that has five static cells.我有一个包含五个静态单元格的 tableview。 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.这些单元格有各种各样的 UIImageViews、UITextFields 等。我在主 UITableViewController .h 文件中创建了 IBOutlets,并直接连接到故事板中的静态单元格 UITextfields。 You can't do that.你不能那样做。

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.看来您可以将 IBOutlets 从 UITableViewCell 的子类直接连接到主 UITableViewController .h 文件。 You just have to make sure that you set the Table View Content field to "Static Cells".您只需要确保将表视图内容字段设置为“静态单元格”。 I missed that step.我错过了那一步。

Here is an image to illustrate:这是一张图片来说明:截图 Select 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:.我发现我遇到的问题是我在故事板中设置了静态单元格,然后尝试在委托方法 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.如果您使用静态单元格,则不需要使用任何单元格设置委托方法。

Here is some excellent reading that also helped me out: Apple TableView Programming Guide这里有一些很棒的阅读也对我有帮助: Apple TableView 编程指南

For what it's worth, the problem seems to be related to two IBOutlet objects declared in my .m file.就其价值而言,问题似乎与我的 .m 文件中声明的两个IBOutlet对象有关。 One was referencing a UISlider and the other a UILabel .一个是引用UISlider ,另一个是UILabel I removed the references and then declared them as class variables instead.我删除了引用,然后将它们声明为类变量。 In viewDidLoad I hooked them up using [self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET] .viewDidLoad我使用[self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET]它们连接起来。 Looks like the same solution as mentioned by f.perdition in the link above.看起来与上面链接中 f.perdition 提到的解决方案相同。

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.我创建了一个故事板 X,在其中添加了一个视图控制器 Y。 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.然后我将视图控制器 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.删除了其中一个引用,此后问题未出现。

In my use case I have added a new target that runs the build script that is using xcodebuild .在我的用例中,我添加了一个运行使用xcodebuild的构建脚本的新目标。 I was receiving the same failures but the reason was Mac Catalyst support being YES by default in Build Settings .我收到了同样的失败,但原因是 Mac Catalyst 支持在Build Settings 中默认为YES (My main target doesn't support Mac Catalyst.) Changing those to NO in Builds Settings fixed the issue for me. (我的主要目标不支持 Mac Catalyst。)在Builds Settings中将这些更改为NO为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM