嵌入容器视图时,ARSCNView为nil

时间:2017-10-09 14:58:20

标签: swift xcode augmented-reality arkit uicontainerview

我有MainGameViewController,它有一个容器视图,嵌入ViewController,这是我用模板ARKit应用程序获得的初始UIViewController。这意味着它有一个ARSCNView对象和故事板的出口,在代码中如下所示:

@IBOutlet var sceneView: ARSCNView!

如果ViewController是我的初始ViewController,则可行。但如果我使用它嵌入式,我会遇到unexpectedly found nil崩溃。我已经尝试断开连接并重新连接IBOutlet。这是我设置委托时发生崩溃的ViewDidLoad代码:

override func viewDidLoad() {

    super.viewDidLoad()

    // Set the view's delegate
    sceneView.delegate = self

    // Show statistics such as fps and timing information
    sceneView.showsStatistics = true

    // Create a new scene
    let scene = SCNScene()
    // Set the scene to the view
    sceneView.scene = scene
    addGun()
}

这里有一些有用的截图 enter image description here

enter image description here

enter image description here

0 个答案:

没有答案