Question

I have xib with two CustomView (NSView *one, NSView *two),how i addSubview in AppDelegate?

self.content = [[ContentViewController alloc]
                initWithNibName:@"ContentViewController"
                bundle:nil];
[[[[self vertical] subviews] objectAtIndex:1] addSubview:[_content one]];

This way don't work.

Was it helpful?

Solution

Each view should be in it's own NIB file, as the NSViewController only has a single view instance variable.

So the answer is to split each view into it's own NIB; set the custom class correctly and then set the File Owner to NSViewContoller and connect the view from the controller to the custom view.

You then load each separately and add their views whereever you like (taking care to keep a reference to the NSViewController used to load the view).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top