I want to program a game with a tab bar controller. I have added a tabbar controller to a ViewController with a button segue and a new file with the scene to be displayed is programmed to the respective view controller of the Tab bar. But the error message "Could not CastValue of type 'UIView' (0x10dfede60) to 'SKView' (0x10cdba800). (Lldb") on (I have also created a new gamecene). What have I done wrong or is there an easier way for this?
PS: I am a Swift beginner, so do not take it so bad, if I am not very know.
The view conztrollers of the tab bar:
import UIKit
import SpriteKit
class SecondViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
/
if let scene = SKScene(fileNamed: "secondScene") {
/
scene.scaleMode = .aspectFill
/
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
/
/
/
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
/
/
}
*/
}
The GameViewController:
import UIKit
import SpriteKit
import GameplayKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
/
if let scene = SKScene(fileNamed: "GameScene") {
/
scene.scaleMode = .aspectFill
/
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
override var shouldAutorotate: Bool {
return true
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown
} else {
return .all
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
override var prefersStatusBarHidden: Bool {
return true
}
}