我尝试以编程方式将NSDrawer
添加到我应用的主窗口(其中还有NSOutlineView
已在IB中设置):
的Ivar:
var dd: NSDrawer? = nil
然后,当点击显示三角形按钮时:
if dd == nil {
var drawer_rect = NSInsetRect(self.window.frame, 30, 30).size
drawer_rect.height = 150
dd = NSDrawer.init(contentSize: drawer_rect, preferredEdge: NSRectEdge.minY)
dd!.contentView = self.status_scroll
dd!.parentWindow = self.window
}
因此,当用户试图披露'抽屉,上面的代码创建一个NSDrawer
,然后显示它。一切正常,但Xcode在设置parentWindow
时转储了以下内容:
[General] ERROR: Setting <NSOutlineView: 0x100f0b9b0> as the first responder for window <NSDrawerWindow: 0x100fc8900>, but it is in a different window (<NSWindow: 0x6080001e0600>)! This would eventually crash when the view is freed. The first responder will be set to nil.
(
0 AppKit 0x00007fff9fc289cf -[NSWindow _validateFirstResponder:] + 557
1 AppKit 0x00007fff9f3a374c -[NSWindow _setFirstResponder:] + 31
2 AppKit 0x00007fff9f90c35b -[NSDrawerWindow _setParentWindow:] + 64
3 AppKit 0x00007fff9f90b666 -[NSDrawer(DrawerInternals) _doSetParentWindow:] + 382
4 AppKit 0x00007fff9f907786 -[NSDrawer setParentWindow:] + 78
注释掉parentWindow的设置,没有任何内容被转储到控制台。