Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种简单的方法可以知道何时使用关闭按钮(窗口标题栏的)关闭 NSWindow 。
使用NSWindowDelegate和windowWillClose:(NSNotification *)notification方法我会收到每次关闭的通知。但是我怎么知道关闭请求是由关闭按钮发送的
NSWindowDelegate
windowWillClose:(NSNotification *)notification
用于[yourWindow standardWindowButton:NSWindowCloseButton]找到关闭按钮,然后将其目标和操作更改为自定义方法。
[yourWindow standardWindowButton:NSWindowCloseButton]