Search code examples
iosswiftuigesturerecognizertvosapple-tv

Apple TV - Menu button returns to wrong screen


I have an Apple TV app that starts out with a splash page. It plays a short video and does some setup networking. After these both finish I automatically transition the user to a Landing page for them to sign up for the service.

let langingPageVC = LandingPageViewController(nibName: nil, bundle: nil)

self.present(langingPageVC, animated: true, completion: {
    print("Transferred to landing page")
})

The problem occurs when the user hits the menu button from this point. They are automatically taken back to the splash page, and the app just displays the static image it display while waiting for the networking to complete and stays there. The user can then press the menu button again and exit the app. If the user re-enters the app, they will be on this static image and not be able to do anything.

How can I make it so the app just goes to background directly from my landing page and doesn't go back to the Splash page? I know how to detect the menu press with a gesture recognizer, but there doesn't seem to be a call I can make that will background the application from that point.

I have tried removing the Splash page from its parent in the completion block and that didn't work. I saw something about setting the page as the keyWindow but I got a message in the log saying not to do that and that the system is supposed to handle it, and it also didn't work.

Any help is appreciated.


Solution

  • Two possible options:

    • Instead of presenting LandingPageViewController from SplashViewController, you could set LandingPageViewController as rootViewController. That way your splash will not be in your backstack of viewcontrollers.
    • Present SplashViewController in a separate window over LandingPageViewController. Once your video finishes you can dismiss the window.