【发布时间】:2017-02-05 08:57:44
【问题描述】:
当谈到 UIKit 和 ViewControllers 时,我是个菜鸟。我正在尝试从SplashScreenViewController 切换到GameViewController,这是一个SKView。 GameViewController 加载正常,因为我可以听到游戏音乐开始,但 SplashScreenController 永远不会从屏幕上消失。所以基本上我有SplashScreenController 留在屏幕上,我可以听到GameViewController 在后台启动。我做错了什么?
这是SplashScreenViewController的代码:
class SplashScreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor(red: 46/255, green: 83/255, blue: 160/255, alpha: 1.0)
let image : UIImage = UIImage(named:"splashScreen.png")!
let bgImage = UIImageView(image: image)
bgImage.frame = CGRect(origin: CGPoint(x: 3,y: -3), size: CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height))
self.view.addSubview(bgImage)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "GameViewController")
self.present(controller, animated: true, completion: nil)
self.dismiss(animated: true, completion: nil)
}
deinit {
print("Object with name SplashScreenViewController is being released")
}
}
【问题讨论】:
-
很简单,请在dismissViewController方法完成时呈现nextviewcontroller。
-
有趣的想法,但我想它只有在
SplashScreenViewController被解雇后还剩下一个视图控制器时才有效。
标签: ios swift uiviewcontroller sprite-kit uikit