0

我的故事板上有一个普通的视图控制器设置,附加到“登陆”页面快速视图控制器类。我正在尝试使用这个流行的库创建一个演练动画:https ://github.com/mamaral/Onboard

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

有人可以帮忙吗?

这是我在“着陆”类的 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)

谢谢

4

2 回答 2

1

正如我们在此处的 Objective-C 演示应用程序中看到的那样,您应该将此代码包含在您的 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
    }
于 2015-12-16T02:00:33.530 回答
0

如果您将代码粘贴在 viewWillAppear() 事件中,它将全部呈现。

于 2016-01-31T19:22:28.930 回答