Search code examples
iosxcodeswift3bwwalkthrough

Make BWWalkthrough library start at launch


I'm a little stuck with the BWWalkthrough library which i'm trying to implement at application launch. I have two storyboards the Main one and SlidesFlow storyboard. I set the main interface to be SlidesFlow and set the initial story board as SlidesFlow. I did create 1 view for BWWalkthroughViewController and an other 4 for BWWalkthroughPageViewController. In my AppDelegate in the didFinishLaunchingWithOptions function I used the following code:

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

    // Get view controllers and build the walkthrough
    let stb = UIStoryboard(name: "SlidesFlow", bundle: nil)
    let walkthrough = stb.instantiateViewController(withIdentifier: "SlideShow") as! BWWalkthroughViewController
    let page_zero = stb.instantiateViewController(withIdentifier: "Slide_1")
    let page_one = stb.instantiateViewController(withIdentifier: "Slide_2")
    let page_two = stb.instantiateViewController(withIdentifier: "Slide_3")
    let page_three = stb.instantiateViewController(withIdentifier: "Slide_4")

    // Attach the pages to the master
    walkthrough.delegate = self
    walkthrough.addViewController(page_one)
    walkthrough.addViewController(page_two)
    walkthrough.addViewController(page_three)
    walkthrough.addViewController(page_zero)

    return true
}

Shouldn't this work? Am I missing something?


Solution

  • Found the problem, it seems that didFinishLaunchingWithOptions function wasn't being called at all I think because I transferred my project from xcode 7 to xcode 8. So if anybody is struggling with a similar issue, just replace the old didFinishLaunchingWithOptions function

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

    with this:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool