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

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

问题描述

我向我的应用程序委托添加了一个 applicationShouldOpenUntitledFile 方法,返回 NO 作为 Apple 的文档指定.但是,我仍然在启动时收到一个新文档.怎么了?

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天全站免登陆