xcode 在 iOS 中为 Storyboard 指定 App Delegate
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21226993/
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
Specify App Delegate for Storyboard in iOS
提问by Sepehrom
I'm trying to change my App's main interface which currently is set to a .xib file in the project's "General Configuration Pane" to a new storyboard.
我正在尝试将我的应用程序的主界面更改为新的故事板,该界面当前设置为项目“常规配置窗格”中的 .xib 文件。
I have created the storyboard, and selected it as the main interface. But when I launch the application in simulator, I get a black screen and the following message printed in the console : "There is no app delegate set. An app delegate class must be specified to use a main storyboard file."
我已经创建了故事板,并选择它作为主界面。但是,当我在模拟器中启动应用程序时,出现黑屏并在控制台中打印以下消息:“没有设置应用程序委托。必须指定应用程序委托类才能使用主故事板文件。”
How should I do that ?
我该怎么做?
采纳答案by codercat
did you set mainWindow if you are not please set your window in your project
你是否设置了 mainWindow 如果你没有请在你的项目中设置你的窗口
回答by Dave Batton
The app delegate class is generally specified in main.m:
app委托类一般在main.m中指定:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([TCAppDelegate class]));
}
}
回答by Saurav Mac
In didFinishLaunchingWithOptions
method put these code lines .
在didFinishLaunchingWithOptions
方法中放置这些代码行。
UIStoryboard *storyBoard; = [UIStoryboard storyboardWithName:@"yourStoryboardName" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
return Yes ;