ios - How make a transition between several ViewControllers from SKScene? -


I want to change my ViewController with the game censen with the spritkit. I have 3 scenes with 3 different view controllers

When my application starts with PresentationViewController, my transition code does not work to my GameScene (GameViewController) GameOverViewController (see screenshot 1) and I have an error Can read messages. screenshot1

Error message:

  whose view is Not in the window hierarchy!   

My code:

  to storyboard = UIStoryboard (name: "Main" bundle: nil) to settingController: UIViewController = storyboard.instantiateViewControllerWithIdentifier ( " ?? PresentationViewController ") VC as the UIViewController = self.view .window .rootViewController VC is really .presentViewController (settingController, animated: completion: zero)   

and when my app Begins with GameViewController (see screenshot 2) transition code works perfectly.

screenshot2

I do not know why this is about 2 cases There is a difference between

The transition between PresentationViewController and GameViewController for information is accompanied by a UIButton with this code.

  override viewDidLoad () {super.viewDidLoad () function var playButton = UIButton the image as UIButton.buttonWithType (UIButtonType.System) = UIImage (name: "playButton.png") UIImage PlayButton.frame = CGRectMake (0, 0, 100, 100) playButton.center = CGPointMake (self.view.frame.width / 2, self.view.frame.height / 1.7) playButton.addTarget (self, action "transition:", forControlEvents: UIControlEvents. TouchUpInside) playButton.setBackgroundImage (image, forState: UIControlState.Normal) self.view.addSubview (playButton)} func transition (from: UIButton!) {Println ( "transition") other See ViewController = self.storyboard? .instantiateViewControllerWithIdentifier ("GameViewController") UIViewController secondViewController.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve self.presentViewController (secondViewController, in animated form: true, completion: zero)}    

< Div class = "text" itemprop = "text">

Well, I found a way to navigate between several ViewController by me.

  self.presentViewController (secondViewController: I make this code in the secondViewController  rootViewController ) to replace  function transition ()  in my PresentationViewController file set animated: true, completion: zero) `  

the code (with options) by:

  secondViewController.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve Go window = UIApplication .sharedApplication () windows [0] as UIWindow UIViewktransitionFromView (WindowkrootViewController Kview, ToView: SecondViewControllerkview, Length: 0.65 Options: KTransitionCrossDissolve, completion: finished {window.rootViewController = secondViewController })    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -