Thursday 15 March 2012

objective c - osx switch between two nsviews -


I want to switch between two NSView controls by pressing the button. Basically, I have a .xib file that has NSWindow control, in the window there are two subviews and some buttons I have dragged the item into the NSViewController list and another There are references to NSView in xib NSViewController from NSWindow and see that the xib file is floating in.

The question is, how do I press the NSWindow button between nsview1 and nsview2? Is this the right way to do it?

sketch

Define an NSView outlet for placeholders where there is property to use in the context of the use of current view controller along with swappable view.

  @ Property (assign) IBotlate NSVU * Main Viv; @ Property (strong) NSViewController * currentViewController;   

I use a common method for visual swapping (using autolay to see full placeholder view)

  - (zero) SetMainViewTo: Remove (NSViewController *) controller {// Existing subviews ([[self.mainView subviews]] gt; & gt; {[self.mainView.subviews [0] deletedFrosporiviv];} NSView * view = [controller view]; [View set transclusions atorizingismask intactstationes: no]; [Manuewe ed sbewview: view]; ns Dictionary * viewDictionary = NSDictionaryOfVariableBindings (view); [Add the self-add menuSeventions: [NSLUT Constant Handicap Specially: @ "V: | [View] |" Option: 0 Metric: Zero View: viewsDictionary]]; [Add Self.mainView Adjustment: [NSLoot Constant Handicap Specially: @ "H: | [View] |" Option: 0 Metric: Zero View: ViewsDictionary]]; Self.currentViewController = Controller;}   

IBOutlets are defined to immediately and swap the view controller Can

  - (IBAction) showView1: (id) sender {View1Controller * controller = [[View1Controller alloc] init]; [Self setmanView: controller]; } - (IBAction) showView2: (ID) sender {View2Controller * controller = [[View2Controller alloc] init]; [Self setmanView: controller]; }    

No comments:

Post a Comment