2

I am going to make an OS X application with several views and windows.

It has several screens - splash, login/register and the main screen(and so on).

I tried to use NSWindowControllers. However, it's so complex to use and I'm confused.

What is the best experience in the view/window transitions?

Yun
  • 5,233
  • 4
  • 21
  • 38
  • Are your windows all in the same xib file? – rdelmar Oct 15 '12 at 05:10
  • http://stackoverflow.com/questions/2115257/how-to-use-nswindowcontroller and http://stackoverflow.com/questions/3683349/nswindowcontroller-clarification-of-understanding will help you out. – parilogic Oct 15 '12 at 05:11

2 Answers2

3

The main pattern I use is the follow:

  • Create a New File User Interface Window and save it as nameYouLike
  • Create a New File Cocoa Objective-C class of NSWindowController subclass and save is as nameYouLikeDelegate
  • Go to nameYouLike NSWindow and change it's File's Owner Class to nameYouLikeDelegate
  • Connect window and other objects you need of xib with an IBOutlet to nameYouLikeDelegate.h
  • In some init/show method do this:

    - (void)showWindow {
        if (!self.window) {
            [NSBundle loadNibNamed:@"nameYouLike" owner:self];
        }
    
        [self.window makeKeyAndOrderFront:self];
    }
    
  • Save reference in some way (f.e. in AppDelegate or NSWindowController of another window):

    nameYouLikeDelegate *fNameYouLikeDelegate;
    
  • Now when you need to create your window you use:

    fNameYouLikeDelegate = [[nameYouLikeDelegate alloc] init];
    
  • And to show it:

    [fNameYouLikeDelegate showWindow];
    
Shebuka
  • 3,148
  • 1
  • 26
  • 43
1

How would you like to transition? It's probably unnecessary to transition between windows in your case. Better you make a NSViewController and transition between the subviews of the window. You should check out the basics of Cocoa.

You can then use the animator property of the views.

[[self.view animator] setAlphaValue:0.0];
IluTov
  • 6,807
  • 6
  • 41
  • 103