OS X中Windows之间的转换 [英] Transition between windows in OS X

查看:148
本文介绍了OS X中Windows之间的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要制作一个带有多个视图和窗口的OS X应用程序.

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).

我尝试使用NSWindowControllers.但是,使用起来非常复杂,我很困惑.

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?

推荐答案

我使用的主要模式如下:

The main pattern I use is the follow:

  • 创建一个New File User Interface Window并将其另存为nameYouLike
  • 创建NSWindowController子类的New File Cocoa Objective-C class,并另存为nameYouLikeDelegate
  • 转到nameYouLike NSWindow并将其File's Owner Class更改为nameYouLikeDelegate
  • 使用IBOutletwindow和其他需要的xib对象连接到nameYouLikeDelegate.h
  • 在某些init/show方法中执行此操作:

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

  • 以某种方式保存引用(例如,在另一个窗口的AppDelegateNSWindowController中):

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

  • 这篇关于OS X中Windows之间的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆