ios 在 XCode 中创建新的“空应用程序”时没有 .xib 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7313150/
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
There is no .xib file when I create a new "Empty Application" in XCode
提问by Ayush Agarwal
I am working through the Big Nerd Ranch Guide (2nd Ed) for iOS Programming using Xcode version 4.2.
我正在使用 Xcode 4.2 版完成 iOS 编程的 Big Nerd Ranch Guide(第二版)。
For the very first project I'm asked to create a new project which is a "Window-based Application" the description for which reads "This template provides a starting point for any application. It provides just an application delegate and a window". The "Window-based Application" option was not available to me in XCode 4.2 but I did see the option to create a "New Empty Application" which has the same description ("This template provides a starting point for any application. It provides just an application delegate and a window")
对于第一个项目,我被要求创建一个新项目,它是“基于窗口的应用程序”,其描述为“此模板为任何应用程序提供了一个起点。它仅提供一个应用程序委托和一个窗口”。“基于窗口的应用程序”选项在 XCode 4.2 中对我不可用,但我确实看到了创建具有相同描述的“新空应用程序”的选项(“此模板为任何应用程序提供了起点。它仅提供一个应用程序委托和一个窗口")
When I create the project I'm supposed to have a MainWindow.xib file but that does not show up at all in my project? Help please
当我创建项目时,我应该有一个 MainWindow.xib 文件,但它根本没有出现在我的项目中?请帮忙
回答by dreamwitz
When you create the project, don't forget to uncheck the option "storyboard". Once you uncheck it, you can see the xib files.
创建项目时,不要忘记取消选中“故事板”选项。取消选中它后,您可以看到 xib 文件。
回答by Steve Ham
I am using the same book, had the same problem but I figured how to fix it.
我正在使用同一本书,遇到了同样的问题,但我想出了如何解决它。
- Create a new xib file by
- 创建一个新的 xib 文件
right click Quiz folder -> New File -> iOS -> User Interface -> Window -> click Next
右键单击测验文件夹 -> 新建文件 -> iOS -> 用户界面 -> 窗口 -> 单击下一步
- click the Window.xib file then find an Object and drag it under Objects -> select the third tab on the right -> change this class to AppDelegate
- 点击Window.xib文件然后找到一个Object拖到Objects下->选择右边的第三个tab->把这个类改成AppDelegate
click File's Owner -> change this class to UIApplication -> click the 6th tab and connect delegate to Window
单击 File's Owner -> 将此类更改为 UIApplication -> 单击第 6 个选项卡并将委托连接到 Window
- goto AppDelegate.h and put IBOutlet in front of UIWindow *window;
- 转到 AppDelegate.h 并将 IBOutlet 放在 UIWindow *window 前面;
goto Window.xib again and connect window under Outlets to Window.
再次转到 Window.xib 并将 Outlets 下的 window 连接到 Window。
Also in plist file add a row key - Main nib file base name type - string value - mainwindow
同样在 plist 文件中添加一个行键 - Main nib 文件基本名称类型 - 字符串值 - mainwindow
Hope this helps.
希望这可以帮助。
回答by d.ennis
You can also create a MainWindow.xib afterwards:
您还可以在之后创建 MainWindow.xib:
File > New > File >
There should be a Window.xib
. If not, creat an empty .XIB file and drag a window (UIWindow
) into your Objects pane. Copy the connections as they are displayed in the book.
应该有一个Window.xib
. 如果没有,请创建一个空的 .XIB 文件并将一个窗口 ( UIWindow
) 拖到您的对象窗格中。复制书中显示的连接。
Hope that helps.
希望有帮助。
PS.:I recommend to not use beta software to start with iOS
PS.:iOS 开始建议不要使用 beta 软件
回答by Roger
If you create a empty project and dowant to use storyboading, then do:
如果您创建了一个空项目并且确实想使用故事板,请执行以下操作:
- create empty project
- add new file (storyboard)
- make sure to add a correct entry in your app-info.plist file. (Just create a simple project with storyboard and look-up the key there in the app-plist).
- throw a view controller on the board, and off you go.
- 创建空项目
- 添加新文件(故事板)
- 确保在您的 app-info.plist 文件中添加正确的条目。(只需创建一个带有故事板的简单项目,然后在 app-plist 中查找密钥即可)。
- 在板上扔一个视图控制器,然后就可以了。
Like this you have a nice clean project, withthe use of the storyboard feature.
这样你有一个干净的项目,与使用故事板功能。
回答by Roger
Please read this in the official Forum to the Book. BNR posted a project that you can use as your default Project for all Chapters in this Book. They created a small Project that looks as if you created an empty project with the XCode version before iOS5 was released.
请在本书的官方论坛中阅读此内容。BNR 发布了一个项目,您可以将其用作本书所有章节的默认项目。他们创建了一个小项目,看起来就像您在 iOS5 发布之前使用 XCode 版本创建了一个空项目一样。
http://forums.bignerdranch.com/viewtopic.php?f=74&t=1817
http://forums.bignerdranch.com/viewtopic.php?f=74&t=1817
regards
问候
Thomas
托马斯