문제

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.

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top