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.
windowWillClose调用该方法时,如何防止我的 NSWindow 被关闭?
windowWillClose
你不能。等到windowWillClose:叫到的时候,已经晚了。您需要在此之前使用 停止它windowShouldClose:。
windowWillClose:
windowShouldClose:
快速示例:
您需要设置的委托NSWindow和实施NSWindowDelegate
NSWindow
NSWindowDelegate
func windowShouldClose(_ sender: NSWindow) -> Bool { return false }