[英]Storyboard doesn't contain a controller with identifier 'MainWindow'
I am trying to instantiate an NSWindowController
from a storyboard in my OS X app:我正在尝试从我的 OS X 应用程序中的故事板实例化一个
NSWindowController
:
NSWindowController *mainWindowController = [[NSStoryboard storyboardWithName:@"Main" bundle:nil] instantiateControllerWithIdentifier:@"MainWindow"];
But this is what I'm getting:但这就是我得到的:
Storyboard (<NSStoryboard: 0x618000008500>) doesn't contain a controller with identifier 'MainWindow'
. Storyboard (<NSStoryboard: 0x618000008500>) doesn't contain a controller with identifier 'MainWindow'
。
But in the storyboard:但是在故事板中:
It is set.它被设置。 No, there are no other storyboards.
不,没有其他故事板。 Yes, I've tried cleaning the project and the build folder, but nothing changes.
是的,我试过清理项目和构建文件夹,但没有任何变化。
Why would I get this error?为什么我会收到这个错误?
UPDATE: I am building my app, coming back to the storyboard, and I see that Storyboard ID is unset:更新:我正在构建我的应用程序,回到故事板,我看到故事板 ID 未设置:
How can Storyboard ID get unset by itself? Storyboard ID 如何自行取消设置?
It was definitely a bug with Xcode.这绝对是 Xcode 的一个错误。 Restarting Xcode solved the problem.
重新启动Xcode解决了这个问题。
Confirmed in 11.3.在 11.3 中确认。 This is such a time-waster, together with this one:
这太浪费时间了,再加上这个:
How do I open another window in macOS in Swift with Cocoa 如何在 macOS 中使用 Cocoa 在 Swift 中打开另一个窗口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.