为什么不调用applicationShouldOpenUntitledFile? [英] Why isn't applicationShouldOpenUntitledFile being called?

查看:216
本文介绍了为什么不调用applicationShouldOpenUntitledFile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向我的应用程序委托中添加了applicationShouldOpenUntitledFile方法,并按照Apple的文档规定返回了NO.但是,我仍然在启动时得到一个新文档.怎么了?

I added a applicationShouldOpenUntitledFile method to my application delegate, returning NO as Apple's documentation specifies. However, I'm still getting a new document on startup. What's wrong?

@implementation AppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSLog( @"This is being called" );
}

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
    NSLog( @"This never is" );
    return NO;  
}

@end

推荐答案

您正在运行Lion.在添加applicationShouldOpenUntitledFile处理程序之前运行时,创建了一个新文档.现在,有了10.7的退出并重新打开应用程序时还原窗口",您的应用程序将还原那个无标题窗口,而不是像您想象的那样创建一个新窗口.

You're running Lion. When you ran before adding the applicationShouldOpenUntitledFile handler, a new document was created. Now, with 10.7's "Restore windows when quitting and re-opening apps", your application is restoring that untitled window, and not creating a new one as you suppose.

关闭该窗口并重新运行您的应用程序,将调用applicationShouldOpenUntitledFile并禁止创建新的无标题文件.

Close that window and re-run your application, and applicationShouldOpenUntitledFile will be called and will suppress the creation of a new untitled file.

这篇关于为什么不调用applicationShouldOpenUntitledFile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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