How to perform segue from within a SKScene?

前端 未结 2 986
南旧
南旧 2020-12-11 16:24

I have been trying to perform a segue from within a sprite kit SKScene layer. My application requires the user to touch an image on the scene that would push up a new UIView

相关标签:
2条回答
  • 2020-12-11 16:47

    Swift version :

    self.view!.window!.rootViewController!.performSegueWithIdentifier("gameOverSegue", sender: self)
    
    0 讨论(0)
  • 2020-12-11 17:02

    Segues belong to view controllers, not SpriteKit scenes. If you want to perform a segue from within a SpriteKit node's event handling code, you'll need to look up the view controller that owns the view presenting the scene. For example, in a SKScene subclass' touchesBegan:withEvent: method:

    UIViewController *vc = self.view.window.rootViewController;
    [vc performSegueWithIdentifier:@"id" sender:nil];
    
    0 讨论(0)
提交回复
热议问题