gpt4 book ai didi

objective-c - cocoa windowDidEnterFullScreen 没有被调用

转载 作者:行者123 更新时间:2023-12-03 17:10:46 26 4
gpt4 key购买 nike

我正在编写一个 Cocoa 应用程序,它应该在全屏模式下工作。我想检测用户将应用程序窗口设置为全屏模式。在 Xcode 中,

  1. 在属性检查器中,全屏值为“主窗口”
  2. 在文件检查器中,未选中“使用自动布局”
  3. 主窗口 View 未选中“自动调整 subview 大小”

我在 AppDelegate.h 中将 AppDelegate 设为 NSWindowDelegate

@interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>

并在 AppDelegate.m 中有一个类似的方法

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

但是这个方法没有被调用,因为没有 NSLog 输出。未达到该方法中设置的监视。

我做错了什么?我错过了什么?

请帮忙!我对 cocoa 相当陌生,并且为此奋斗了一整天。谢谢

最佳答案

您实际上需要使 AppDelegate 成为窗口的委托(delegate)。您必须将窗口的 delegate 导出连接到 NIB 中的 AppDelegate,或者需要以编程方式设置窗口的 delegate 属性。

关于objective-c - cocoa windowDidEnterFullScreen 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30280025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com