让SKView = SKView给出错误

时间:2015-06-10 12:23:55

标签: ios swift

我正在学习本教程https://www.youtube.com/watch?v=hLOhirsXx9c并在Gameviewcontroller.swift中收到错误

' ='

之后的预期初始值

代码是

import UIKit
import SpriteKit

class GameViewController: UIViewController {

    var scene: GameScene!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Configure the view
        let Skview = as Skview
        Skview.multipletouchenabled = false
        // Create and Configure the Scene
        scene = GameScene(size: Skview.bounds.size)
        scene.filllmode = .AcpectFill

        // Pressent The Scene

        Skview.PresentScene(scene)
           }

    override func shouldAutorotate() -> Bool {
        return true
    }

    override func supportedInterfaceOrientations() -> Int {
        if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
            return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
        } else {
            return Int(UIInterfaceOrientationMask.All.rawValue)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Release any cached data, images, etc that aren't in use.
    }

        override func prefersStatusBarHidden() -> Bool {
            return true
        }
    }

错误发生在let skview = as Skview

1 个答案:

答案 0 :(得分:3)

我不确定你要做什么,但问题在于:

let Skview = (Missing Variable Here To Cast) as Skview

我将假设这是视图控制器,你想要的是什么 let skView = view as SKView