0

So, I've been playing around with Sprite Kit and Swift stuff, and I was trying to transition between a game scene and a regular UIVewController when I encountered an issue. It returns an error when the actual program is run. Here is my code:

var mainStoryboard = UIStoryboard(name: "Main.storyboard", bundle: nil)
var vc = mainStoryboard.instantiateViewControllerWithIdentifier("menu") as! UIViewController
self.view!.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)

Here is the error:

Could not find a storyboard named 'Main.storyboard' in bundle NSBundle //bundle location here... (irrelevant)

Does anybody know why this isn't working? When I look at the view on the left of the screen, I see that the storyboard file's name is "Main.storyboard". Did I do something blatantly wrong?

Any help is appreciated! Thanks in advance!

  • What do you mean '"transition between a game scene and a regular UIViewController"? A `UIViewController` contains an `SKView` which contains an `SKScene`... – ABakerSmith May 17 '15 at 15:26
  • my UIViewController does not contain an SKView –  May 17 '15 at 15:40
  • How are you displaying your `SKScene` then? You need an `SKView` to present an `SKScene`. – ABakerSmith May 17 '15 at 15:54
  • I don't really understand what you mean. I am presenting a menu scene--which is a UIViewController--from an SKScene. –  May 17 '15 at 15:56

1 Answers1

1

The name of the storyboard is simply "Main" instead of "Main.storyboard". From the documentation:

The name of the storyboard resource file without the filename extension. This method raises an exception if this parameter is nil.

Dániel Nagy
  • 11,815
  • 9
  • 50
  • 58