-2

In my app I have a piece of code that allows to go automatically from one Vc to another Vc after a short period of time. The problem is that when the second Vc pops out id doesn't cover up all the screen. How can I make it cover up the whole screen and not let the user go back? Here is the code:

import UIKit

class InitialViewController: UIViewController {
override func viewDidLoad() {
    super.viewDidLoad()
    
    let delay : Double = 2.0    // 4 seconds here
    DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
        let firstViewController = storyBoard.instantiateViewController(withIdentifier: "firstViewController") as! firstViewController
        self.present(firstViewController, animated:true, completion:nil)
    }
}

}
  • 1
    Possible duplicate of: [Presenting modal in iOS 13 fullscreen](https://stackoverflow.com/questions/56435510/presenting-modal-in-ios-13-fullscreen) – TylerP Apr 09 '22 at 21:40
  • Is your final goal to replace one controller with another or keep the first controller in memory for later use? – The Dreams Wind Apr 09 '22 at 22:18

1 Answers1

0

You must present the controller modally with fullscreen. Then they cannot swipe from the top to dismiss the controller.

import UIKit

class InitialViewController: UIViewController {
override func viewDidLoad() {
    super.viewDidLoad()
    
    let delay : Double = 2.0    // 4 seconds here
    DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
        let firstViewController = storyBoard.instantiateViewController(withIdentifier: "firstViewController") as! firstViewController
        firstViewController.modalPresentationStyle = .fullScreen
        self.present(firstViewController, animated: true, completion: nil)
    }
}

}
NDCoder
  • 93
  • 2
  • 8