【问题标题】:Add Playground to a Storyboard project: Could not find a storyboard ... in bundle NSBundle将 Playground 添​​加到 Storyboard 项目:在 bundle NSBundle 中找不到故事板 ...
【发布时间】:2017-03-30 05:52:55
【问题描述】:

我有一个使用 Storyboard 的 iOS 项目。然后我添加了一个包含以下内容的游乐场文件:

import UIKit
import PlaygroundSupport
import SpriteKit

var str = "Hello, playground" 
let gameViewController = GameViewController.loadFromStoryboard() // <<<<- Fails
PlaygroundPage.current.liveView = gameViewController

我在loadFromStoryboard()

NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle 

我应该解决什么问题? 关于上述标题/内容的 stackoverflow 有大量问题,但是,每个问题都有一个非常具体的场景。在过去的几天里,我经历了很多,我认为由于使用了 Playground,我的场景是不同的,因此我再次发布。

【问题讨论】:

    标签: ios swift swift-playground


    【解决方案1】:

    如果这是在现有项目中,您可以使用完整的包标识符来实例化情节提要,如 here 所示:

    let myBundle = Bundle(identifier: "com.asad.MyProgram")
    let storyboard = UIStoryboard(name: "MyStoryboard", bundle: myBundle)
    

    请注意,这确实要求游乐场与具有特定捆绑标识符的项目位于同一工作区。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-31
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多