gpt4 book ai didi

ios - 使用 Onboard Swift Library 但它显示为空白?

转载 作者:行者123 更新时间:2023-11-29 01:26:11 25 4
gpt4 key购买 nike

我的 Storyboard上有一个普通的 View Controller 设置,它附加到“登陆”页面快速 View Controller 类。我正在尝试使用这个流行的库创建一个漫游动画:https://github.com/mamaral/Onboard

我从库的源代码中下载了 4 个文件,并使用桥接 header 将它们链接到我的项目中。但是当我运行这个项目时,我被卡住了。页面是空白的,什么也没有显示。 Onboard 页面标题、图像,什么都没有。它是空白的。我看不出有什么问题,而且我到处搜索,没有任何信息或任何使用此库的 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
}

关于ios - 使用 Onboard Swift Library 但它显示为空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33986761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com