xcode 在 Storyboard 中设置的 rootViewController 未在应用启动时显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8260036/
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
rootViewController set in Storyboard not showing on App Launch
提问by tarheel
I started with an Empty Application and added the storyboard file myself, added a View Controller to the storyboard and then embedded it into the Navigation Controller. Now, when I launch the app in iOS Simulator - nothing shows. Screenshot of my storyboard is below.
我从一个空的应用程序开始,自己添加了故事板文件,在故事板中添加了一个视图控制器,然后将其嵌入到导航控制器中。现在,当我在 iOS 模拟器中启动应用程序时 - 没有显示。我的故事板的屏幕截图如下。
What needs to happen to get the "AddPerson" to show on launch?
需要做什么才能让“AddPerson”在发布时显示?
Update: Yes, Main Storyboard is set, but the Main Interface is blank. Should that Main Interface be set to something(the drop down is blank)?
更新:是的,主情节提要已设置,但主界面为空白。该主界面是否应该设置为某些内容(下拉列表为空)?
采纳答案by tarheel
I searched and searched, and finally found my answer(@jms - hope this answers yours as well). See here: Xcode 4.2 iOS Empty Application and storyboards.
我搜索和搜索,终于找到了我的答案(@jms - 希望这也能回答你的问题)。请参阅此处:Xcode 4.2 iOS 空应用程序和故事板。
回答by
Just comment out all your generated code in app delegate's - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method except for return YES
.
只需在应用程序委托的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法中注释掉所有生成的代码,除了return YES
.
Here's my code and it worked fine.
这是我的代码,它运行良好。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
// [self.window makeKeyAndVisible];
return YES;
}
回答by louis
I had the same problem, just select both of them CMD+X to cut, then CMD+V to paste it will set one as root view :)
我遇到了同样的问题,只需选择它们 CMD+X 进行剪切,然后 CMD+V 粘贴它就会将其设置为根视图:)