Search code examples
swiftxcode11

modalPresentationStyle command Doesn't change to fullscreen


I'm making a game on Xcode 11 using Storyboards, and I have two storyboards for the game and if you lose. My problem is that the default presentation is modal and not fullscreen, so I did some research and found this

vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)

So I tried it by putting it in my function that ends the game, which is

func endGame() {
        let storyboard = UIStoryboard(name: "GameOver", bundle: nil)
        let controller = storyboard.instantiateViewController(withIdentifier: "GameOverView")
        self.present(controller, animated: true, completion: nil)
        vc.modalPresentationStyle = .fullScreen
        self.present(vc, animated: true, completion: nil)
    }

But it does nothing, Xcode doesn't even throw an error if I wrote it wrong. I even tried taking that out of the function and putting it right after every time I called the endGame function, but that still didn't work. I'm sure this is the right thing to do, because I also watched a video that showed someone using this and it worked, but for some reason it didn't for me, even though I did what they did by putting these lines in the Button IBAction functions. What am I doing wrong here?


Solution

  • You must set your navigation controller's presentation style as fullScreen.

    enter image description here