Storyboard不包含标识符为'MainWindow'的控制器

问题描述 投票:8回答:2

我正在尝试从OS X应用程序中的情节提要中实例化NSWindowController

NSWindowController *mainWindowController = [[NSStoryboard storyboardWithName:@"Main" bundle:nil] instantiateControllerWithIdentifier:@"MainWindow"];

但是这就是我得到的:

Storyboard (<NSStoryboard: 0x618000008500>) doesn't contain a controller with identifier 'MainWindow'

但是在情节提要中:

enter image description here

已设置。不,没有其他情节提要。是的,我尝试清理项目和构建文件夹,但没有任何变化。

为什么会出现此错误?

更新:我正在构建我的应用程序,回到情节提要,但我看到未设置情节提要ID:

enter image description here

情节提要ID本身如何无法设置?

objective-c macos storyboard nsstoryboard
2个回答
19
投票

这绝对是Xcode的错误。重新启动Xcode解决了该问题。


0
投票

在11.3中确认。这是一个浪费时间的东西,再加上一个:

How do I open another window in macOS in Swift with Cocoa

© www.soinside.com 2019 - 2024. All rights reserved.