在我开始在故事板上添加按钮之前,App的构建还不错,然后我得到了上面的错误。它停留在我的GameViewController中的这一行代码。
let scnView = self.view as! SCNView故事板本身将其自定义类设置为GameViewController (没有SCNView选项)。GameViewController本身是从UIViewController继承的。我正在使用Xcode7.2。
发布于 2016-02-10 18:37:01
确保在文件顶部导入SceneKit。
import SceneKit打开“Main.storyboard”文件。选择ViewController ->视图,转到“标识检查器”,并将->字段更改为SCNView。SceneKit帮助
发布于 2016-12-19 14:08:25
如果您是以编程方式设置所有这些内容,而不使用故事板,请确保执行以下步骤:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow()
let gameViewController = GameViewController()
window?.rootViewController = gameViewController
window?.makeKeyAndVisible()
return true
}
let scnView = SCNView(frame: view.frame)
view.addSubview(scnView)
发布于 2021-07-28 02:03:52
如果以编程方式执行此操作,请添加以下代码:
override func loadView() {
//sort of like changes type of self.view from UIView to SCNView
self.view = SCNView()
}https://stackoverflow.com/questions/35323147
复制相似问题