Closed Geeroz closed 8 years ago
The same error in my situation.
Here is the code:
let page1 = OnboardingContentViewController(title: "", body: "ONBOARDING1".l, image: UIImage(named: "onboarding-page-1"), buttonText: "NEXT".l) { () -> Void in
}
let page2 = OnboardingContentViewController(title: "", body: "ONBOARDING2".l, image: UIImage(named: "onboarding-page-2"), buttonText: "NEXT".l) { () -> Void in
}
let page3 = OnboardingContentViewController(title: "", body: "ONBOARDING3".l, image: UIImage(named: "onboarding-page-3"), buttonText: "NEXT".l) { () -> Void in
}
let page4 = OnboardingContentViewController(title: "", body:"ONBOARDING4".l, image: UIImage(named: "onboarding-page-4"), buttonText: "ONBOARDING_GO".l, actionBlock: { (controller) -> Void in
controller?.dismiss(animated: true, completion: {
})
})
let pages = [page1, page2, page3, page4]
for page in pages {
page?.bodyLabel.font = UIFont.systemFont(ofSize: 18)
page?.iconImageView.contentMode = .scaleToFill
page?.topPadding = 1
page?.underTitlePadding = -200
page?.iconWidth = viewController.view.bounds.width
page?.iconHeight = viewController.view.bounds.height
page?.actionButton.titleLabel?.font = UIFont.systemFont(ofSize: 14)
page?.movesToNextViewController = true
}
let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "onboarding-background"), contents: pages)
onboardingVC?.shouldMaskBackground = false
onboardingVC?.modalTransitionStyle = .crossDissolve
viewController.present(onboardingVC!, animated: true, completion: nil)`
I haven't look at swift for Onboard since like Swift 1.2 so I'm assuming there'll need to be a decent amount of changes, but haven't had any time to look into it. Feel free to debug and open a pull request if you're able, otherwise it may be a bit until I support Swift 3.
Okay. I'll try to fix it. Thank's for your response.
vite7, any luck finding the solution for this issue?
I was used this in one of my projects, so I need to fix it anyway. I'll make a pull request when its done.
On Sep 18, 2016, at 6:59 PM, Derekhie notifications@github.com wrote:
vite7, any luck finding the solution for this issue?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Thanks vite7
Same problem for me! Thanks vite7!
Same Problem here too Thanks @vite7
@vite7 Any fix yet?
I have the fix. Each of the pages is actually an Optional!
at the end of your page initializers. For example:
let firstPage = OnboardingContentViewController.content(withTitle: "Welcome", body: "Welcome message", image: icon, buttonText: nil) {
}!
OR
... contents: [page1!, page2!, page3!] ...
So to "fix" this issue we just need to update the README. I will submit a PR for this.
So, PR #154 fixes the issue so that OnboardingContentViewController instances are no longer optional values. Until this change is merged, use the workaround above and force unwrap these instances.
v2.3.1 was just pushed and should be available shortly.
After update to Xcode 8 I got this crash.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue setDelegate:]: unrecognized selector sent to instance 0x60000024d9b0' * First throw call stack: (
)
Here is the code that I use to create Onboarding in AppDelegate.swift
` func generateOnBoardViewController()-> OnboardingViewController { print("(#function)") // Initialize onboarding view controller // var onboardingVC = OnboardingViewController() let icon = UIImage(named: "empty-biz") let firstPage = OnboardingContentViewController.content(withTitle: "Welcome", body: "Welcome message", image: icon, buttonText: nil) { }
Then I check if user is login, if not replace the rootViewController with this code
self.window?.rootViewController = generateOnBoardViewController()
I have try so many init method of OnboardingViewController but none of them works. Any suggestion?