可可窗windowDidEnterFullScreen没有被调用 [英] cocoa windowDidEnterFullScreen not being called

查看:142
本文介绍了可可窗windowDidEnterFullScreen没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写可在全屏模式下运行的Cocoa应用程序。我想检测用户将应用程序窗口设置为全屏模式。
在Xcode中,

I'm writing a Cocoa application which should work in fullscreen mode. I would like to detect the user setting the application window to fullscreen mode. In Xcode,


  1. 在属性检查器中,全屏值为主窗口

  2. 在文件检查器中,未选中使用自动布局

  3. 主窗口视图中的自动调整大小子视图未选中

我正在AppDelegate.h中使AppDelegate成为NSWindowDelegate,

I'm making the AppDelegate an NSWindowDelegate like this in AppDelegate.h

@interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>

,并在AppDelegate.m中使用类似方法。m

and have a method like this in AppDelegate.m

-(void) windowDidEnterFullScreen:(NSNotification *)notification
{
   vuMain.view.frame = NSMakeRect(0, 0, window.frame.size.width, 
   window.frame.size.height);
   NSLog(@"AppDelegate - windowDidEnterFullScreen");
}

由于没有NSLog输出,因此未调用此方法。无法达到该方法中设置的手表。

But this method is not getting called as there is no NSLog output. A watch set in the method does not get reached.

我在做什么错?我想念什么?

What am I doing wrong? What am I missing?

请帮助!我对可可很陌生,为此整整挣扎了一天。
谢谢

Please help! I'm rather new to Cocoa and am struggling for one full day with this. Thanks

推荐答案

您需要实际制作 AppDelegate 窗口的代表。您必须将窗口的 delegate 出口连接到NIB中的 AppDelegate ,或者需要设置窗口的委托属性。

You need to actually make the AppDelegate the window's delegate. You either have to connect the window's delegate outlet to the AppDelegate in the NIB, or you need to set the window's delegate property programmatically.

这篇关于可可窗windowDidEnterFullScreen没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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