Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I code what view controller is linked to the continue button? #26

Open
swells808 opened this issue Apr 23, 2018 · 3 comments
Open

Comments

@swells808
Copy link

Hi, I didn't see in the documentation or the example a guide on how to link up the continue button to link the click action to another view controller did I miss something?

Also it would seem you would want to run this in a first run situation, do you have a preferred method of detecting first run and launching SwiftyOnboard?

@Sajad47
Copy link

Sajad47 commented May 12, 2018

I want to know the answer of your question

@juanpablofernandez
Copy link
Owner

Here's a quick way of linking up that continue button with an action to take you to another ViewController

    @objc func handleContinue(sender: UIButton) {
        let index = sender.tag
        if index == 2 {
           //Replace the '2' with the amount of onboarding screens that you have - 1
           //Perform your segue
            return
        }
        swiftyOnboard?.goToPage(index: index + 1, animated: true)
    }

@juanpablofernandez
Copy link
Owner

juanpablofernandez commented May 12, 2018

Also it would seem you would want to run this in a first run situation, do you have a preferred method of detecting first run and launching SwiftyOnboard?

This is my approach in the AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        if isFirstLaunch() {
        //Do whatever you need to do on first launch
        }
        return true
    }

func isFirstLaunch() -> Bool {
        let hasLaunched = UserDefaults.standard.bool(forKey: "appHasLaunched")
        if !hasLaunched {
            //First Launch
            UserDefaults.standard.set(true, forKey: "appHasLaunched")
            return true
        } else {
            //It's not first Launch
            return false
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants