Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
- Subject: Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
- From: Graham Cox <email@hidden>
- Date: Sun, 25 Oct 2015 23:14:56 +1100
> On 25 Oct 2015, at 5:51 am, Nick <email@hidden> wrote:
>
> What am I doing wrong?
>
This:-
> self.window.contentView = self.vc.view;
>
A NSWindow is not itself a NSView, so it needs to have a closely associated view that hosts all the rest of the window’s content. That is the contentView. It should remain behind all other views, and be the root view of the window’s view hierarchy. It is owned by the window, and is exposed mainly so that you can add subviews to it, though you can replace it with a specific view subclass if that makes sense - it still must be the root view in your window. There’s some new NSWindow API in 10.10+ that allows you to instantiate a window and set the contentView using a view controller - maybe that’s confusing you, or this addition has exposed a problem with what you’re doing that you happened to get away with previously.
What you’re attempting sounds reasonable, just that setting any child view to the window’s root view is obviously going to mess up the view hierarchy, with undefined results.
I’m not sure what your code ought to be doing exactly, but something like this replacing the line I’ve picked out may do it:
[self.window.contentView addSubview:self.vc.view];
—Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden