Here is the way I navigate between different ViewControllers:
let newViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "viewController3")
UIApplication.topViewController()?.present(newViewController, animated: true, completion: nil)
with the following extension:
extension UIApplication {
class func topViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(base: nav.visibleViewController)
}
if let tab = base as? UITabBarController {
if let selected = tab.selectedViewController {
return topViewController(base: selected)
}
}
if let presented = base?.presentedViewController {
return topViewController(base: presented)
}
return base
}
}
And here is the way I invoke scene transitions in my SKScene (several):
let transition = SKTransition.fade(withDuration: 2)
let nextScene = NewScene(size: scene!.size)
nextScene.scaleMode = .aspectFill
scene?.view?.presentScene(nextScene, transition: transition)
Everything work fine before switching ViewControllers. Once the switching has been succeeded, I can not invoke transition anymore in my SKScene, the app get frozen without any error from Xcode (iPad connected to the Mac with live debugging)
Do you know what happens ?
I use Swift 3 and SpriteKit with ViewControllers to be able to use Vuforia static lib in a direct ViewController scene (UIView).