Andrew Andrew - 5 months ago 52
Swift Question

Mamaral onboarding library in swift

Helo, I'm having trouble getting my onboarding System to work. I am using this framework:
https://github.com/mamaral/Onboard

This demo for the framework only comes in objective-c, I have done my best to create my own version in swift and am almost finished but I am stuck on a way to move to another storyboard after the final screen. This is my code at the moment:

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {


func setupNormalRootViewController() -> Void {

self.window?.rootViewController = LoginViewController

}


let firstPage = OnboardingContentViewController(title: "Welcome To my App", body: "App Mesage", image: UIImage(named: "heart"), buttonText: "") {}
let secondPage = OnboardingContentViewController(title: "...", body: "Message", image: UIImage(named: "Mint"), buttonText: "") {}

let thirdPage = OnboardingContentViewController(title: "title", body: "abcd", image: UIImage(named: "Choco"), buttonText: "End", action: { setupNormalRootViewController() } ) {}

let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "blueBackground"), contents: [firstPage, secondPage,thirdPage])




self.window?.rootViewController = onboardingVC
}
}


I am calling "setupNormalRootViewController" in the "thirdPage" variable but there seems to be no way to move on past the initial onboarding screen even though I have set a specified method to run when pressing the button on the last screen.

Answer
    class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?



func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.




    let firstPage = OnboardingContentViewController(title: "Welcome To my App", body: "App Mesage", image: UIImage(named: "heart"), buttonText: "") {}
    let secondPage = OnboardingContentViewController(title: "...", body: "Message", image: UIImage(named: "Mint"), buttonText: "") {}

    let thirdPage = OnboardingContentViewController(title: "title", body: "abcd", image: UIImage(named: "Choco"), buttonText: "End") { () -> Void in
        self.setupNormalRootViewController()
    }

    let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "blueBackground"), contents: [firstPage, secondPage,thirdPage])


    self.window?.rootViewController = onboardingVC


    return true
}

func setupNormalRootViewController() -> Void {

    self.window?.rootViewController = ViewController()

}
}