应用程序正在构建正常,直到我开始向故事板添加按钮然后我得到上述错误.它停在我的GameViewController内的这行代码中.
let scnView = self.view as! SCNView
Run Code Online (Sandbox Code Playgroud)
故事板本身的自定义类设置为GameViewController(SCNView没有选项).GameViewController本身继承自UIViewController.我正在使用Xcode7.2.
确保还在文件顶部导入SceneKit.
import SceneKit
Run Code Online (Sandbox Code Playgroud)
打开"Main.storyboard"文件.选择ViewController - > View转到"Identity Inspector"并将Class字段更改为SCNView. SceneKit帮助
小智 6
如果您在没有故事板的情况下以编程方式设置所有这些内容,请确保执行以下步骤:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow()
let gameViewController = GameViewController()
window?.rootViewController = gameViewController
window?.makeKeyAndVisible()
return true
}Run Code Online (Sandbox Code Playgroud)
let scnView = SCNView(frame: view.frame)
view.addSubview(scnView)Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2839 次 |
| 最近记录: |