On Aug 10, 2017, at 11:38 , J.E. Schotsman <jesc...@xs4all.nl> wrote:
> No, it’s a xib-based app.

I think it’s a bit harder, because with a storyboard you can use segues, and 
set them up in IB.

With the proviso that I haven’t tried what I’m about to suggest, here’s how I 
understand what you’d need to do:

1. Make a separate XIB file for a view controller (parent) and separate XIB 
files for a view controller for each view that your popup switches between 

2. Delete the tab that you previously were using for this from the window XIB 
(or wherever it is).

3. Instantiate the parent view controller and child view controllers from their 
various NIBs, and assemble them into a hierarchy (2 deep) using the parent’s 
addChildViewController, or setting the childViewControllers array directly.

3. Programmatically (e.g. in a viewDidLoad or windowDidLoad) create a new 
NSTabViewItem using the init(viewController:) initializer.

4. Add this new tab to your tab view.

5. Invoke transition(from:to:options:completionHandler:), probably in an action 
method in the parent view controller, to switch between its child views.

(“Parent” in this case means relative to the switchable view. It is, of course, 
nested within the tab view/view controller hierarchy.)

If you don’t want to create a new tab programmatically, you can avoid that step 
by keeping the existing tab item, with nothing in its view, and adding the 
parent view controller’s view as a subview of the tab item’s (now empty) view, 
introducing an extra level of views.

Also, you’ll need to pay attention to auto-layout constraints, to make sure 
that the the tab view sizes propagate down to the sub-hierarchy you add.

As I say, I haven’t tried this, so I may be overlooking something crucial, but 
I think this would be the general approach.

P.S. If you don’t need to use "transition(from:to:options:completionHandler:)” 
specifically, there are likely easier ways of getting much the same effect. For 
example, you implement the contents of *that* one tab’s view as a nested 
tab-less tab view, and use tab switching of the inner tab view when choosing an 
item in the popup. That leaves child view controllers out of the picture, which 
simplifies the necessary infrastructure. If you really want child view 
controllers (which is a good thing!), you have to do something like the above, 
or switch to a storyboard and use segues.


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to