我正在使用 NSWindowDelegate 编写一个应用程序。但是,当我调整窗口大小时,它不会调用函数:
func windowDidResize(notification: NSNotification)
这是我的课
class ViewController: NSViewController, NSWindowDelegate {}
和 Storyboard:
我将委托(delegate)链接到我的窗口。 但这不起作用。你能帮我解决这个错误吗?谢谢。
最佳答案
您已声明窗口委托(delegate):
class ViewController: NSViewController, NSWindowDelegate {}
当您的屏幕截图显示窗口 Controller (而不是 View Controller )被指定为委托(delegate)时。
将您的窗口 Controller 设置为委托(delegate)接收者。例如:
class MyWindowController : NSWindowController, NSWindowDelegate {}
关于macos - NSWindowDelegate 函数无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32412284/