【发布时间】:2015-09-18 14:53:06
【问题描述】:
我正在使用故事板进行 OSX 开发。我正在使用 NSTableView 并且不同的 NSTableRowViews 用于此表视图的行。这是逻辑-
func getRowView(#forIndex:Int) -> NSTableRowView?{
if forIndex == lastSelectedRow{
var storyboard = NSStoryboard(name: "Settings", bundle: nil)
var accountController = storyboard?.instantiateControllerWithIdentifier("account") as! CMMAccountViewController
accountController.accountData = listOfAccounts[forIndex]
var rowView = accountController.view as! CMMAccountView
return rowView
}
else{
var rowView = tableView.makeViewWithIdentifier("accountSeetingsRow", owner: self) as! CMMAccountRowView
rowView.titleLable.stringValue = listOfAccounts[forIndex].nickname!
rowView.captionLable.stringValue = listOfAccounts[forIndex].accountDisplayName!
return rowView
}
}
问题:我有一个按钮在视图中,其视图控制器在行实例化 -
var accountController = storyboard?.instantiateControllerWithIdentifier("account") as! CMMAccountViewController
我让 CTRl 从 CMMAccountViewController 中的该按钮拖动了一个动作,但是每当我单击该按钮时,应用程序就会因 EXE_BAD_ACCESS 而崩溃。 为什么会这样?我应该如何在 NSTableRowView 中使用该按钮?
【问题讨论】:
标签: macos swift cocoa storyboard nstableview