无法将类型"UIView"的值强制转换为"SCNView" [英] Could not cast value of type 'UIView' to 'SCNView'
问题描述
在我开始向故事板添加按钮之前,应用程序运行良好,然后出现上述错误.它在我的GameViewController内部的这一行代码处停止.
App was building fine until I started adding buttons to the storyboard then I got the above error. It stops at this line of code inside my GameViewController.
let scnView = self.view as! SCNView
情节提要板本身已将其自定义类设置为GameViewController(SCNView则没有选项).GameViewController本身继承自UIViewController.我正在使用Xcode7.2.
The storyboard itself has its custom class set to GameViewController (theres no option for SCNView). GameViewController itself inherits from UIViewController. Im using Xcode7.2.
推荐答案
确保还要在文件顶部导入SceneKit.
Make sure to also import SceneKit at the top of the file.
import SceneKit
打开"Main.storyboard"文件.选择ViewController-> View转到"Identity Inspector",并将"Class"字段更改为SCNView. SceneKit帮助
Open the "Main.storyboard" File. Select ViewController -> View go to "Identity Inspector" and change the Class field to SCNView. SceneKit Help
这篇关于无法将类型"UIView"的值强制转换为"SCNView"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!