我在情节提要中有一个普通的视图控制器设置,该设置附加到“着陆”页面swift view controller类。我正在尝试使用以下流行的库创建演练动画:https://github.com/mamaral/Onboard
我从库的源代码下载了这4个文件,并使用桥接头将它们链接到我的项目中。但是当我运行该项目时,我陷入了困境。页面为空白,没有任何显示。机载页面标题,图像,什么也没有。是空白我看不到出什么问题了,我到处搜索,没有信息,也没有使用该库的Swift示例。
有人可以帮忙吗?
这是我在“ Landing”类的viewDidLoad()期间调用的函数中的代码。
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)
谢谢
最佳答案
正如我们在Objective-C演示应用程序here中看到的那样,您应该将此代码包含在AppDelegate中的didFinishLaunchingWithOptions
方法下,并正确设置rootViewController
。这是一个示例(未经测试):
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
}