I'm finishing up a SpriteKit-based app, and just added a button to the main storyboard, and connected it to an IBAction func in the GameViewController. I have multiple scenes within my game, and I only want the button to display in the Game Over scene. Right now it is on the screen throughout all of my scenes. I can't figure out how to hide this button in all of my scenes except for the Game Over one.
Code in GameViewController:
@IBAction func shareToFacebook(){
var shareToFacebook: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
shareToFacebook.setInitialText("J....")
shareToFacebook.addImage(UIImage(named: "AppLogo180.png"))
let vc: UIViewController = self.view!.window!.rootViewController!
vc.presentViewController(shareToFacebook, animated: true, completion: nil)
}
This is everything that's in my viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
self.setShareButtonHidden(true)
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
// Configure the view.
let skView = self.view as! SKView
skView.showsFPS = false
skView.showsNodeCount = false
self.canDisplayBannerAds = false
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
}