打开一个“欢迎"来自主应用程序窗口的窗口 [英] Opening a "Welcome" window from main application window

查看:29
本文介绍了打开一个“欢迎"来自主应用程序窗口的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 OSx 开发可视化编辑器应用程序

I am working on a visual editor application for OSx

当前,应用程序打开我的 MainMenu.xib.我想在打开应用程序时向用户展示一个欢迎窗口,列出以前打开的项目,以及一个创建新项目的按钮(实际上链接到我的 App Delegate menuNewProject 方法)

Currently, the application opens my MainMenu.xib. I would like to present user when opening the application with a Welcome window, listing the previous opened projects, and a button to create a new project (actually linking to my App Delegate menuNewProject method)

打开这个欢迎"xib 而不是 MainMenu xib 的最佳方法是什么?

What is the best approach to open this "Welcome" xib instead of MainMenu xib ?

让我当前的应用代表像这样打开欢迎 xib 吗?

Make my current app delegate open the Welcome xib like this ?

Welcome *welcome = [[Welcome alloc] initWithWindowNibName:@"Welcome"];

然后隐藏我的 MainMenu 窗口?

and then hide my MainMenu window ?

或者将我的应用程序 Welcome xib 设为起点而不是 MainMenu,然后从那里打开我的可视化编辑器?

Or make the starting point of my application Welcome xib and not MainMenu, and open my visual editor from there ?

感谢您的帮助.

推荐答案

好的,我想我明白了:

结尾

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification

我补充说:

[self.window orderOut:nil]; // hide application window
Welcome *welcome = [[Welcome alloc] initWithWindowNibName:@"Welcome"];
[welcome.window makeKeyAndOrderFront:self];
[[NSApplication sharedApplication] runModalForWindow:welcome.window]; // display splash screen

在我的 Welcome.m 文件中,我在启动窗口上添加了一个关闭按钮:

In my Welcome.m file, I added a close button on the splash window :

-(void)windowDidLoad
{
    [super windowDidLoad];

    NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:NSTitledWindowMask];
    [closeButton setFrameOrigin:NSMakePoint(0, 410)];
    NSView* contentView = self.window.contentView;
    [contentView addSubview:closeButton];

    [closeButton setTarget:[AppDelegate appDelegate]];
    [closeButton setAction:@selector(closeModal:)];
}

在 AppDelegate.m 中,我添加了一个 closeModal 方法,它负责关闭我的欢迎屏幕并显示应用程序窗口:

And in AppDelegate.m, I added a closeModal method which is in charge of closing my welcome screen and display the application window:

-(void) closeModal:(id)sender
{
    [[NSApplication sharedApplication] stopModal];
    [self.window orderFront:nil];
}

似乎有效,也许我应该添加一些东西来从内存中丢弃我的欢迎屏幕.

Seems to work, maybe I should add something to discard my Welcome screen from memory too.

这篇关于打开一个“欢迎"来自主应用程序窗口的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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