Transition between windows in OS X [closed]

馋奶兔 提交于 2019-12-07 19:29:46

问题


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?


回答1:


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];
    



回答2:


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];


来源:https://stackoverflow.com/questions/12889534/transition-between-windows-in-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!