可可窗windowDidEnterFullScreen没有被调用 [英] cocoa windowDidEnterFullScreen not being called
问题描述
我正在编写可在全屏模式下运行的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,
- 在属性检查器中,全屏值为主窗口
- 在文件检查器中,未选中使用自动布局
- 主窗口视图中的自动调整大小子视图未选中
我正在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屋!