【发布时间】:2019-06-07 15:15:19
【问题描述】:
我正在使用以下简单代码来初始化 Playground 中的情节提要:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier:"ViewController")
PlaygroundPage.current.liveView = controller
ViewController 是嵌入在可可触摸框架中的公共类,因为我想与 Playground 共享此代码,但出现此错误:
如果我用一个简单的 UIViewController 创建一个新的故事板,一切正常。有什么想法吗?
【问题讨论】:
-
尝试instantiateInitialViewController方法
-
我试过但同样的事情
-
如何在 Playground 中嵌入和导入框架?
-
我使用 cocoa touch 框架创建了一个新目标,其中包含主故事板和所有类文件。如果我创建一个新的故事板它的工作,问题在于主故事板和初始视图控制器。
-
在我的 Playground(在资源中)添加 Storyboard 后,我看到了同样的错误。 Storyboard 有一个带有名称和 ID 的 UIViewController,我尝试像您一样实例化它。
标签: ios swift uiviewcontroller storyboard swift-playground