简体   繁体   中英

Swift 3: make button present ViewController, how?

I would like my button to reshow the user my on boarding screen since it includes some important instructions to my app. The first time I show my onboarding screen is after the first launch; My current function looks like this:

@IBAction func anleitung(sender: RoundButtons) {

    let appDelegate = AppDelegate()
    appDelegate.window?.rootViewController?.present(OnboardingScreen(), animated: true, completion: nil)

}

This is actually like the 4th way I tried this, but, apparently, none of them worked. Do you know how to do that?

Thanks for having a look! Have a great day!

@IBAction func anleitung(sender: RoundButtons) {
    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    appDelegate.window?.rootViewController?.present(OnboardingScreen(), animated: true, completion: nil)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM