0

I have a normal view controller setup on my storyboard attached to a "Landing" page swift view controller class. I'm trying to create a walkthrough animation, using this popular library: https://github.com/mamaral/Onboard

I downloaded the 4 files from the library's source code, and linked them in my project using a bridging header. But when I run the project, I'm stuck. The page is blank, and nothing is showing up. The Onboard page titles, images, nothing. It's blank. I can't see what's wrong, and I've searched everywhere, no info or any Swift example of using this library.

Can someone help?

Here's the code I have in a function that's called during viewDidLoad() of the "Landing" class.

let firstPage = OnboardingContentViewController(title: "Page Title 1", body: "Page body goes here.", image: UIImage(named: "icon"), buttonText: "Text For Button") { () -> Void in
        // do something here when users press the button, like ask for location services permissions, register for push notifications, connect to social media, or finish the onboarding process
    }

    firstPage.titleTextColor = UIColor.blueColor()

    let secondPage = OnboardingContentViewController(title: "Page Title 2", body: "Page body goes here.", image: UIImage(named: "icon"), buttonText: "Text For Button") { () -> Void in
        // do something here when users press the button, like ask for location services permissions, register for push notifications, connect to social media, or finish the onboarding process
    }

    // Image
    let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "street_view.png"), contents: [firstPage, secondPage])


    self.presentViewController(onboardingVC, animated: true, completion: nil)

Thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579
trixmasta
  • 233
  • 3
  • 14

2 Answers2

1

As we can see in a Objective-C Demo App here, you should include this code inside your AppDelegate, under the didFinishLaunchingWithOptions method, and set the rootViewController properly. Here's an example (not tested):

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

    let firstPage = OnboardingContentViewController(title: "Page Title 1", body: "Page body goes here.", image: UIImage(named: "icon"), buttonText: "Text For Button") { () -> Void in
            // do something here 
        }

    firstPage.titleTextColor = UIColor.blueColor()

    let secondPage = OnboardingContentViewController(title: "Page Title 2", body: "Page body goes here.", image: UIImage(named: "icon"), buttonText: "Text For Button") { () -> Void in
           // do something here 
        }

    // Image
    let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "street_view.png"), contents: [firstPage, secondPage])

    // Setting the BG color
    self.window?.backgroundColor = UIColor.blackColor()

    // Setting the rootViewController to your onboardingVC
    self.window?.rootViewController = onboardingVC

    return true
    }
Luiz Dias
  • 1,947
  • 17
  • 22
0

if you stick your code in the viewWillAppear() event it will all render.

kennydust
  • 1,135
  • 15
  • 17