简体   繁体   中英

Specify App Delegate for Storyboard in iOS

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.

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 ?

The app delegate class is generally specified in main.m:

int main(int argc, char *argv[])
{
  @autoreleasepool {
      return UIApplicationMain(argc, argv, nil, NSStringFromClass([TCAppDelegate class]));
  }
}

你是否设置了mainWindow如果你不是请在你的项目中设置你的窗口

In didFinishLaunchingWithOptions method put these code lines .

UIStoryboard *storyBoard; = [UIStoryboard storyboardWithName:@"yourStoryboardName" bundle:nil];
 UIViewController *initViewController = [storyBoard instantiateInitialViewController];
      [self.window setRootViewController:initViewController];

return Yes ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM