gpt4 book ai didi

ios - 尝试转换场景时无法将 UIView 的值转换为 SCNView

转载 作者:行者123 更新时间:2023-11-30 13:06:08 26 4
gpt4 key购买 nike

嘿,我有 2 个场景,都以相同的方式设置。我现在所处的场景称为“Extra1”,我试图到达的场景称为 GamePlay。使用此代码没有错误,但每次尝试调用应该让我更改 View Controller 的函数时它都会崩溃。两种 View 都转换良好,直到我尝试转换。错误指向此代码:

let scnView = self.view as! SCNView

这是错误: enter image description here

代码:

     import UIKit
import GLKit
import GameKit
import SceneKit
import StoreKit
import SpriteKit
import QuartzCore
import Foundation
import AVFoundation
import AudioToolbox
import GameController

class Extra1: UIViewController, ADBannerViewDelegate, SKPhysicsContactDelegate,SKSceneDelegate, SCNSceneRendererDelegate, SCNPhysicsContactDelegate {

override func viewDidLoad() {
super.viewDidLoad()

let scnView = self.view as! SCNView

//scnView.delegate = self
scnView.scene = FieldScene
scnView.playing = true
scnView.loops = true
self.view.multipleTouchEnabled = true
scnView.multipleTouchEnabled = true
self.HUDView = GameScene(size: scnView.bounds.size)
self.HUDView.delegate = self
scnView.overlaySKScene = self.HUDView
scnView.delegate = self
scnView.overlaySKScene!.delegate = self
scnView.overlaySKScene!.userInteractionEnabled = true
scnView.backgroundColor = UIColor.clearColor()
scnView.showsStatistics = false

// Error happens when this function is called. If function isnt called the view call justs fine
func MoveControls() {

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("GamePlay")
self.presentViewController(vc, animated: true, completion:nil)


}

更新以下答案: enter image description here

最佳答案

我认为崩溃线位于 GamePlay 场景内。如果是,请打开 Storyboard并将GamePlayViewControllerview类更改为SCNView

关于ios - 尝试转换场景时无法将 UIView 的值转换为 SCNView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39338200/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com