Mac show model Window

简单的创建一个模态对话框
NSApp.runModalForWindow(self.showWindowController.window!)
其中showWindowController 是一个windowController
在windowController中添加window的delegate,并在windowShouldClose方法中做下面操作:
func windowShouldClose(sender: AnyObject) -> Bool {
NSApp.stopModal()
self.window!.orderOut(false)
return true
}
遇到的问题:

  1. 开始没有在windowShouldClose中调用上面两个方法,导致window关闭了,主window还不能接受到焦点,处于假死状态。
  2. 在runModalForWindow时调用了self.showWindowController.window!.setIsVisible(true)方法,导致model出来的窗口,第一次点关闭,不能关掉,而是从一个模态对话框变成了正常的对话框。
  3. window的VisibleAtLaunch属性需要关闭,否者出来的对话框位置可能不对。

你可能感兴趣的:(Mac show model Window)