Xcode 6 - Main.storyboard 仅显示为源代码,缺少 Interface Builder
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28398337/
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
Xcode 6 - Main.storyboard only showing up as source code, Interface Builder missing
提问by Danny
Somehow my Xcode settings got messed up as it would only show my Main.storyboard file as XML code. I've been told this can be fixed by selecting the Interface Builder from the "Open As" menu, but there is nothing under the menu (the only "selection" is a greyed-out "<None>"). I've cleared my Xcode caches, but this does not help. Other than that, my project still compiles properly.
不知何故,我的 Xcode 设置搞砸了,因为它只会将我的 Main.storyboard 文件显示为 XML 代码。有人告诉我这可以通过从“打开为”菜单中选择界面生成器来解决,但菜单下没有任何东西(唯一的“选择”是一个灰色的“<无>”)。我已经清除了我的 Xcode 缓存,但这无济于事。除此之外,我的项目仍然可以正确编译。
How can this be resolved?
如何解决这个问题?
回答by Stephen Paul
As so many people have pointed out, right-click on the file and hover over Open As
and select Default - Interface Builder
.
正如很多人指出的那样,右键单击文件并将鼠标悬停在上面Open As
并选择Default - Interface Builder
.
However, if this is not an option for you because Open As
shows <None>
, make sure you are in the standard editor and not the version editor. Go up to View in XCode menu--> view--> hover over Standard Editorand select Show Standard Editor. Now repeat the steps others have suggested and you should get the results you're looking for.
但是,如果这不是您的选择,因为Open As
显示<None>
,请确保您在标准编辑器中而不是版本编辑器中。转到XCode 菜单中的View-->view--> 悬停在Standard Editor 上并选择Show Standard Editor。现在重复其他人建议的步骤,你应该得到你正在寻找的结果。
回答by SHEREENA T K
change to Standard Editor by clicking 'Command + Enter'key . Then Main.storyboard may show as Interface Builder.
单击“Command + Enter”键更改为标准编辑器 。然后 Main.storyboard 可能会显示为 Interface Builder。
回答by Ben Guthrie
I had the same issue, where "Open As" wasn't an option on the main storyboard, and xibs were also showing as XML.
我遇到了同样的问题,其中“打开为”不是主故事板上的一个选项,而且 xibs 也显示为 XML。
The solution that worked for me was to right click on an xib which did have the "Open as --> Interface Builder" option. Then, I went back to storyboard, and the main storyboard showed up properly.
对我有用的解决方案是右键单击具有“打开方式 --> 界面生成器”选项的 xib。然后,我回到情节提要,主情节提要正确显示。
回答by Douglas
If you go over to the project outline and control click on the storyboard file and hold down the cursor, you will see the option to open as, this will let you open the storyboard as a certain type. Click on that and choose open as story board. Good luck!
如果您转到项目大纲并控制单击故事板文件并按住光标,您将看到打开为的选项,这将使您以某种类型打开故事板。单击它并选择作为故事板打开。祝你好运!
EDIT#1
编辑#1
Sorry, I think I misread your post. I thought you were doing those steps from the menu bar. Not the outline. I am assuming you have restarted Xcode and your computer.
对不起,我想我误读了你的帖子。我以为您是从菜单栏中执行这些步骤的。不是大纲。我假设您已经重新启动了 Xcode 和您的计算机。
回答by JBA
I had this issue with XCode 8, no luck with Open As >menu... and the solution was as follow:
我在 XCode 8 上遇到了这个问题,Open As >menu...没有运气,解决方案如下:
Make sure the Type is Default - Interface Builderin the Identity and Type right panel (see screenshot). In my case it was "Swift source code" selected :
确保“身份和类型”右侧面板中的“类型”为“默认 - 界面生成器”(参见屏幕截图)。就我而言,它选择了“Swift 源代码”:
Now, in the left pane, right-click on your storyboard, and magically then the option Open As > Interface Builder- Storyboard appeared !
现在,在左窗格中,右键单击您的故事板,然后神奇地出现了Open As > Interface Builder- Storyboard选项!
回答by Zebra
I had "Main.storyboard.xml" in Xcode 9 folder but can not see "Default - Interface Builder" in the list of extensions proposed in "Identity and type".
我在 Xcode 9 文件夹中有“Main.storyboard.xml”,但在“Identity and type”中建议的扩展列表中看不到“Default - Interface Builder”。
I simply deleted the .xml extension in the name of "Identity and type" and then I can see again "Default - Interface Builder" in Open as.
我只是删除了以“身份和类型”为名的 .xml 扩展名,然后我可以再次在 Open as 中看到“默认 - 界面生成器”。
回答by Bill
Took some doing but I found how to fix this every time... When you click on the storyboard and it is showing as source, click on the icon that shows the utilities view on the righthand side.. Look for the identity type.. Type should be Default - Interface Builder.. Mine got switch to C Source Code.. Not sure how.. but...
做了一些事情,但我每次都找到了如何解决这个问题......当你点击故事板并且它显示为源时,点击右侧显示实用程序视图的图标......寻找身份类型..类型应该是 Default - Interface Builder.. 我的已经切换到 C 源代码.. 不知道如何.. 但是......
回答by joakim
This is just a quick fix/ long shot, and depending on the specifics of your situation it might not be helpful at all, but you can import and open storyboard files in other projects.
这只是一个快速修复/远景,根据您的具体情况,它可能根本没有帮助,但您可以在其他项目中导入和打开故事板文件。
So, try importing your storyboard file in a new project and see if it displayed correctly there.
因此,尝试在新项目中导入您的故事板文件,看看它是否在那里正确显示。
Has helped me in the past with misbehaving nib files.
过去曾帮助过我处理行为不端的 nib 文件。