Frage

I'm an experienced iOS developer that has recently embarked on a journey to build his first Mac OS app. So far so good, but I've hit upon a weird issue.

I have a single window application (initiated from the default MainMenu.xib file), that pushes some NSViews (from custom NSViewControllers that I've created) on to the NSWindow contentView.

This is working well on my Macbook Air running Mountain Lion, and on another Macbook Pro retina running the latest version of Mavericks. However, I have a third device running Mavericks as well, and I just get a blank screen window there with no views.

So this is the window structure:

NSWindow (custom NSWindow object, initiated with NSBorderlessWindowMask)
    --> NSWindow has a background view, with a solid colour

Then, I have following structure for the content that needs to be displayed in window:

NSViewController (main)
    --> NSViewController sub 1. View is added to the ViewController above
    --> NSViewController sub 2. View is added to the ViewController above
    --> NSViewController sub 3. View is added to the ViewController above

Then I add the main NSViewController (that contain the subparts of the view) to the contentView of the window

self.mainViewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];

[self.window.contentView addSubview: self.mainViewController.view];
[self.window.contentView setNeedsDisplay:YES];

self.mainViewController.view.frame = ((NSView*) self.window.contentView).bounds;

On the Mavericks device where I'm having issues with, I just get to see the NSWindow plus its background view. On all the others everything is working fine.

War es hilfreich?

Lösung

Well, I'm sure I localize things less often than you, but I suspected first that missing NIB resources was the issue, and then that localization was the issue because the NIBs weren't loading and initWithNibName:bundle does look for localized NIBs.

Sounds like you needed Base localization for the subviews to ensure they appear everywhere, which I guess is fairly odd.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top