找不到Segue标识符

时间:2015-05-23 06:59:42

标签: segue identifier

import UIKit
import SpriteKit

extension SKNode {

class func unarchiveFromFile(file : NSString) -> SKNode? {
    if let path = NSBundle.mainBundle().pathForResource(file as String, ofType: "sks") {
        var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)!
        var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData)

        archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
        let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene
        archiver.finishDecoding()
        return scene
    } else {
        return nil
    }
}
}


class GameViewController: UIViewController{

 override func viewDidLoad() {
    super.viewDidLoad()



    if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
        // Configure the view.
        var skView = self.view as! SKView
        skView.showsFPS = false
        skView.showsNodeCount = false

        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true

        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .AspectFill

        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
}


func move(){
    performSegueWithIdentifier("fromGameMoveToMenu", sender: self)
}



}

这是我的GameViewController。我在不同的playcene中引用了这个类。我可以调用func move(){},因此实际调用该函数没有任何问题。我的主故事板中也有一个segue将我的GameViewController连接到我的MenuViewController。 segue标识符名为fromGameMoveToMenu。错误说它无法找到segue标识符。但是,如果我在performseguewithidentifier中添加相同的viewwillappear函数,那么它将起作用。请帮忙!

0 个答案:

没有答案