Mac OS X Cocoa multiview application navigation

后端 未结 3 1948
一生所求
一生所求 2020-12-28 23:50

I\'ve already spent 2 full days trying to figure out how to use NSViewControllers in order to create a multiview application.

Here is what I do.

I have 2 Vie

3条回答
  •  北海茫月
    2020-12-29 00:43

    This isn't much of an answer at the moment, however I have some concerns about your code that I wanted to work through with you.

    • Are you sure you have connected the outlets and actions in Interface Builder. Please verify this.

    • You don't need mainWindow as there is already a window property that points to the main window (verify this in Interface Builder). Also this looks wrong:

      @synthesize mainWindow = mainwindow;
                                   ^
                                   W
      

      So dump that and just use the existing window outlet provided by Xcode.

    • Don't re-create the view controllers if they already exist:

      if (self.secondViewController == nil)
      {
          self.secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController"
                                                                             bundle:nil];
      }
      self.window.contentView = self.secondViewController.view;
      

提交回复
热议问题