我试图在单击NSTableViewCell时打开第二个NSWindow。到目前为止,这是我的代码:
func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
IndiFlightWC.loadWindow()
IndiFlightWC.showWindow(nil)
IndiFlightWC.setMap(indiFlight: FlightList[row]!)
return true
}
和IndiFlightWC初始化如下:
var IndiFlightWC = IndiFlightWindowController()
我在IndiFlightWindowController的windowDidLoad中放置了一个断点,但它从未到达断点。所以我的问题是如何正确显示新窗口?
谢谢!
答案 0 :(得分:0)
您的init方法几乎可以肯定是错误的。
如果您查看documentation for NSWindowController,则会看到那里列出了四种不同的初始化方法。它们都带有参数。
您的IndiFlightWindowController
xib是否包含在您的项目中?为什么不尝试let indiFlightWC = IndiFlightWindowController(windowNibName: "IndiFlightWindowController")
看看会发生什么呢。
其他一些提示:
1)变量名称应以小写字母开头。使用indiFlightWC
代替IndiFlightWC
作为变量名。上限应该是上课的。
2)loadWindow
isn't needed,因为showWindow
应该自动调用loadWindow
。