How to display a View only when the app starts on Swift 4?

Asked

Viewed 99 times

0

Good guys I’m making an app for a Interview I’m almost done but wanted to add more features.

I am doing in Xcode using Swift 4 language..

What I’d like to know is, I have a View called Popupview how do I present it every time the application starts ??

That is when the application is run by the user, every time, show this View..

  • would be like a logo or app presentation? Make this view in the Launchscreen.storyboard class, it is presented when opening the application, after a while is directed to the application itself

  • I get it, I’ll check it out later.

1 answer

1

Opa, blza?

In his override func viewDidLoad() from your input view (the initial view controller), add the following code to call your Popupview. Doing this it will start the first view, and over it the Popupview.

    let vc = self.storyboard?.instantiateViewController(withIdentifier: "PopUpView") as! PopUpView
    self.present(vc, animated: true, completion: nil)

Put a back button in Popupview and call in your code, to return an initial view, will be the following:

    navigationController?.popViewController(animated: true)
    dismiss(animated: true, completion: nil)

If you just want to add an incoming animation to your app, use Launchscreen.storyboard, which will be your spahs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.