我的故事板上有一个普通的视图控制器设置,附加到“登陆”页面swift视图控制器类。我正在尝试使用这个流行的库创建一个演练动画: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)
由于
答案 0 :(得分:1)
正如我们在Objective-C演示应用here中看到的那样,您应该在didFinishLaunchingWithOptions
方法下的AppDelegate中包含此代码,并正确设置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
}
答案 1 :(得分:0)
如果您将代码粘贴到viewWillAppear()事件中,它将全部呈现。