NSWindowController and NSViewController
Probably a pretty simple question, but I can't get my head around it.
I would like to create some sort of wizard: An NSWindow appears as a sheet from another NSWindow and should show three different NSViews one after another.
I think I should create a custom NSWindowController and three NSViewControllers but I don't know how to how to set up the controllers and how开发者_如何学运维 to exchange the views.
In a nutshell, your window controller would instantiate the three view controllers, have a host view, and add -[NSView addSubview:] or remove -[NSView removeFromSuperView] the view controllers’ views as subviews of the host view. Depending on how you structure your code, you can also use -[NSView replaceSubview:with:] to replace a subview with another one.
Apple’s View Controller sample code features view switching using view controllers.
@Bavarious asnwer is good, folks like me always need a good snippet of code:
appDelegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];
self.masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
[appDelegate.window.contentView replaceSubview:self.view with:self.masterViewController.view];
I create the appDelegate object because it is being called from an NSViewController otherwise you can get the view from self.
加载中,请稍侯......
精彩评论