从 Swift 5 / Cocoa 中的 tableView 从一个故事板转到另一个故事板
搜索该主题但找不到有效的解决方案。
我正在构建一个带有多个故事板的会计应用程序。主要、客户(客户)、发票(事实)...等。我可以通过单击按钮从主故事板转到发票故事板的客户,没问题...按钮(主 SB)链接到客户或发票故事板参考。
在客户故事板中,我有一个表视图,其中列出了该客户的购买历史记录。我希望能够双击特定发票,并在发票情节提要中打开该发票。
双 CLI 部分工作正常,打印消息工作...但程序崩溃后显示消息:无法将类型 '__NSCFBoolean' (0x7fffaab000c8) 的值转换为 '__C.NSViewControllerPresentationAnimator' 该代码是从另一篇文章中获取并改编的。我尝试了不同的变体但没有成功,即相同的错误消息。
我还没有从事将发票号码从客户端 SB 传输到发票 SB 的部分。我可能会使用 segue 传输发票编号,并让发票程序在加载
发票故事板文件名:factures.storyboard 后查看该变量是否为 nil。 制造视图控制器类:FacturesVC ViewControllerstoryboardID:facturesVC_id
@objc func tableViewDoubleClick(_ sender:AnyObject) {
if tableView.selectedRow >= 0 {
print ("VC545:", tableView.selectedRow)
//let storyboard = NSStoryboard(name: "factures", bundle: nil)
//let VC = storyboard.instantiateViewController(withIdentifier: "facturesVC_id") // give same error
let VC = NSStoryboard(name: "factures", bundle: nil).instantiateController(withIdentifier: "facturesVC_id") as! FacturesVC
self.present(VC as NSViewController, animator: true as! NSViewControllerPresentationAnimator)
}
}
have search on that topic without finding a solution that work.
I am building a accounting application with several storyboard. Main, Customer( clients), invoice (factures)... etc. I can go from the main storyboard to the customer of Invoice storyboard by click a button no problem... The button (main SB) is linked to the Customer or Invoice storyboard reference.
In the clients storyboard, I have a tableView with that list the purchased historic of that customer. I would like to to be able to double clic on a specific invoice, and open that invoice in the Invoice storyboard.
The double clic part work fine, print message work... but the program crash after with the message: Could not cast value of type '__NSCFBoolean' (0x7fffaab000c8) to '__C.NSViewControllerPresentationAnimator'
That code was taken andadapted from another post. I have tried different variation withou success ie same error message.
I have not work on the part where I transfer the Invoice number from the client SB to the Invoice SB. I will likely transfer the Invoice number with a segue and have the Invoices program look if that variable if not nil, after loading
Invoice storyboard filename : factures.storyboard
facture ViewController Class : FacturesVC
ViewController storyboardID : facturesVC_id
@objc func tableViewDoubleClick(_ sender:AnyObject) {
if tableView.selectedRow >= 0 {
print ("VC545:", tableView.selectedRow)
//let storyboard = NSStoryboard(name: "factures", bundle: nil)
//let VC = storyboard.instantiateViewController(withIdentifier: "facturesVC_id") // give same error
let VC = NSStoryboard(name: "factures", bundle: nil).instantiateController(withIdentifier: "facturesVC_id") as! FacturesVC
self.present(VC as NSViewController, animator: true as! NSViewControllerPresentationAnimator)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的代码没有意义。
您似乎正在尝试调用
present(_:animator:)
。如果您调用它,则需要向其传递一个动画器(NSViewControllerPresentationAnimator
类型的对象。)。您的代码不会创建
NSViewControllerPresentationAnimator
。以下是您需要如何更改它的概述:
我以前没有使用过 NSViewControllerPresentationAnimator 。 (这些天我主要使用 iOS。)如果您不确定如何继续,您可能应该搜索有关
NSViewControllerPresentationAnimator
的教程。Your code does not make sense.
It looks like you are trying to call
present(_:animator:)
. If you call that, you need to pass it an animator (an object of typeNSViewControllerPresentationAnimator
.)Your code does not create a
NSViewControllerPresentationAnimator
.Here is an outline of how you need to change it:
I haven't worked with
NSViewControllerPresentationAnimator
s before. (I mostly work with iOS these days.) You should probably search for tutorials onNSViewControllerPresentationAnimator
if you are unsure how to proceed.终于,我找到了我一直在寻找的答案......
这是代码。
Finally, I have found the answer I was looking for...
Here is the code.