6

so maybe this is so easy and I'm being dense but..

I'm trying to open a view controller that is displayed on my main.storyboard programatically from my MenuBarController. The View Controller doesn't have any segues attached to it but I have given the view controller a storyboard ID of Test.

This is for OS X so apologies I'm new to the storyboard and Segue features.

I've been trying this:

let storyBoard = NSStoryboard(name: "Main", bundle: nil)! as NSStoryboard
let myViewController = storyBoard.instantiateControllerWithIdentifier("test") as NSViewController
self.presentViewControllerAsModalWindow(myViewController)

But receive an error:

[NSNib initWithNibNamed:bundle:] could not load the nibName: TestApp.MenuBarController in bundle (null).

Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
Jimmy Jam
  • 107
  • 1
  • 6
  • `var vc = self.storyboard?.instantiateViewControllerWithIdentifier("test") as YourVCName` `self.presentViewController(vc, animated: true, completion: nil)` does this work? Also are you using swift 1.1 or 1.2? – boidkan Feb 20 '15 at 19:10
  • I'm using Swift 1.1 and I'm afraid that code doesn't work... – Jimmy Jam Mar 06 '15 at 16:33
  • 1
    I've finally been put straight. The problem was I was trying to trigger self.presentviewcontroller from a view controller that was in the Application Scene section of the storyboard. It works perfectly firing from any other view actually within the app!! – Jimmy Jam Mar 06 '15 at 17:21

0 Answers0