Xcode 如何决定首先加载哪个 xib?我怎样才能改变它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8219907/
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
How does Xcode decide which xib to load first? How can I change that?
提问by ios-lizard
I have downloaded an Xcode project that has three xibs (A.xib, B.xib, and C.xib). I noticed that:
我下载了一个包含三个 xib(A.xib、B.xib 和 C.xib)的 Xcode 项目。我注意到:
- None of them is called "MainWindow.xib".
- In the project summary the Main Interfacevalue is set to MainWindow
- Main nib file base nameis not set
- Main.cdoes not specify the app delegate either
int retVal = UIApplicationMain(argc, argv, nil, nil);
- 它们都没有被称为“MainWindow.xib”。
- 在项目摘要中,主界面值设置为MainWindow
- 未设置主 nib 文件基本名称
- Main.c也没有指定应用程序委托
int retVal = UIApplicationMain(argc, argv, nil, nil);
Still, when I build&run, the app loads A.xib. How does the app decide what to load?
尽管如此,当我构建和运行时,应用程序会加载 A.xib。应用程序如何决定加载什么?
I am using Xcode 4 and I am targeting iOS 5. Thank you.
我正在使用 Xcode 4,我的目标是 iOS 5。谢谢。
回答by matsr
You can set the Main Interface
in the Summary tab of your app target.
您可以Main Interface
在应用目标的“摘要”选项卡中设置。
See this image:
看这张图片:
EDIT: Or, as Alan wrote, you can set it in your info.plist file.
编辑:或者,正如 Alan 所写,您可以在 info.plist 文件中设置它。
EDIT 2: Oh. I see what your problem is. You can use MainWindow as your main .xib file, but you have to edit which .xib is loaded in MainWindow. Open MainWindow.xib, and select the view controller that is used. If I'm right, its class is set to A
. If you want B.xib to be used, you have to change the class to B
. You will also have to set the NIB being used for the view controller, in the Attribute Inspector.
编辑2:哦。我明白你的问题是什么。您可以使用 MainWindow 作为您的主要 .xib 文件,但您必须编辑在 MainWindow 中加载的 .xib。打开 MainWindow.xib,然后选择使用的视图控制器。如果我是对的,它的类设置为A
. 如果要使用 B.xib,则必须将类更改为B
. 您还必须在属性检查器中设置用于视图控制器的 NIB。
Set the class for the UIViewController being used in MainWindow.xib:
为 MainWindow.xib 中使用的 UIViewController 设置类:
Set the NIB:
设置笔尖:
回答by Alan Zeino
In your application's Info.plist.
在您的应用程序的 Info.plist 中。