Getting Windows to Appear.....


Dave
 

Hi All,

I’m having problems getting a window to appear on the Mac.

This is the first time I’ve used Storyboards on the Mac and I’m not sure I have things setup correctly.

When I created the project I used the single window application template which gave me a Main.storyboard with a Window and View Controller setup. I’m now trying to add the main game window to the App which is in a separate storyboard as it uses Manual Layout. The Window that XCode created I’ve called “Game Setup” and the Window I’ve just added, “Game”. I tried making the Game window the initial window, but this doesn’t seem to do anything.

Ultimately the way I want this to work is for a “Game Setup” window to appear which then opens the Main Game window after the user has had a chance to tweak the settings. For now, I just want the Game Setup window to open and present the Main Game Window.

I added this code to the setup window:

-(void) viewDidAppear
{
NSStoryboard* myStoryboard;
NSWindowController* myGameWindowController;

//**
//** Instantiate the Game Window Controller
//**
myStoryboard = [NSStoryboard storyboardWithName:@"MacManualLayout" bundle:nil];
myGameWindowController = [myStoryboard instantiateControllerWithIdentifier:@"LTWGameWindowController1"];
if (myGameWindowController == nil)
return;

//**
//** Present the Game Window
//**
[myGameWindowController showWindow:nil];

// [myGameWindowController.window orderFront:nil]; //Tried this, but made no difference.
}

myGameWindowController has a View Controller in it in the Storyboard and its being ok as I’ve put a breakpoint in viewDidAppear and it fires ok. However, I just have the Startup window and no Game Window showing. Is there something more I have to do to make it appear?

All the Best
Dave

Join cocoa@apple-dev.groups.io to automatically receive all group messages.