简体   繁体   English

NSWindowDelegate函数无法正常工作

[英]NSWindowDelegate functions cannot work

I'm writing an application using NSWindowDelegate. 我正在使用NSWindowDelegate编写应用程序。 However, when I resize the window, it doesn't call function: 但是,当我调整窗口大小时,它不会调用函数:

func windowDidResize(notification: NSNotification) func windowDidResize(通知:NSNotification)

This is my class 这是我的课

class ViewController: NSViewController, NSWindowDelegate {} 类ViewController:NSViewController, NSWindowDelegate {}

and the storyboard: 和情节提要:

This is my storyboard 这是我的故事板

I linked delegate to my window. 我将委托链接到我的窗口。 But it doesn't work. 但这是行不通的。 Can you help me fix the error? 您能帮我解决错误吗? Thank you. 谢谢。

You've declared your window delegate with: 您已使用以下方法声明了窗口委托:

class ViewController: NSViewController, NSWindowDelegate {}

When your screenshot shows the window controller, not the view controller, as being designated as the delegate. 当屏幕快照显示窗口控制器(而不是视图控制器)被指定为委托时。

Set your window controller to be the delegate recipient. 将您的窗口控制器设置为委托收件人。 EG: 例如:

class MyWindowController : NSWindowController, NSWindowDelegate {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM