Swift 使用车载设备设置视图控制器

Swift 使用车载设备设置视图控制器,swift,uiviewcontroller,Swift,Uiviewcontroller,嘿,伙计们,我现在正在使用机载库,如果你们不知道的话,这里有一个链接 问题是我试图在我的视图控制器中使用它,而不是在应用程序委托中使用它,如示例中所示,这是使用以下代码设置视图控制器 self.window.rootViewController = self.generateSecondDemoVC() 但我似乎无法在我的视图控制器中执行此操作,因为没有此选项,并且它没有编译,如何将视图控制器设置为返回OnboardingViewController的方法 这是我的视图控制器文件 // //

嘿,伙计们,我现在正在使用机载库,如果你们不知道的话,这里有一个链接

问题是我试图在我的视图控制器中使用它,而不是在应用程序委托中使用它,如示例中所示,这是使用以下代码设置视图控制器

self.window.rootViewController = self.generateSecondDemoVC()
但我似乎无法在我的视图控制器中执行此操作,因为没有此选项,并且它没有编译,如何将视图控制器设置为返回OnboardingViewController的方法

这是我的视图控制器文件

//
//  PurchaseViewController.swift
//  News Cartel
//
//  Created by Tunde Adegoroye on 13/12/2015.
//  Copyright © 2015 Tunde Adegoroye. All rights reserved.
//

import UIKit
import Onboard

class PurchaseViewController: OnboardingViewController {

    @IBAction func closeButtonDidTouch(sender: AnyObject) {
        dismissViewControllerAnimated(true, completion: nil)
    }

    func loadFromNewFilters(notification: NSNotification){


    }

    override func viewDidAppear(animated: Bool) {

        // Can't seem to hook it upto the viewcontroller here
        generatePurchasePaging()

    }


    func generatePurchasePaging() -> OnboardingViewController {

        let welcomePage = OnboardingContentViewController(title: "PAY WHAT YOU WANT", body: "I made my app so you could have the best experience reading tech related news. That’s why I want you to value it based on your satisfaction.", image: UIImage(named: "Purchase-Pig"), buttonText: "") { () -> Void in

        }

        let firstPurchasePage = OnboardingContentViewController(title: "MINT", body: "The app is great but there’s still a few places in room of improvement. If this is your feeling this is for you.", image: UIImage(named: "Purchase-Mint"), buttonText: "69p") { () -> Void in

        }

        let secondPurchasePage = OnboardingContentViewController(title: "SWEET", body: "IThis is the suggested price where you value the time I spent on development and design. Feel free to pay more or less.", image: UIImage(named: "Purchase-Lolly"), buttonText: "£1.49") { () -> Void in

        }

        let thirdPurchasePage = OnboardingContentViewController(title: "GOLD", body: "Hello is it me your looking for, if this popped into your mind using the app then this is the price for you.", image: UIImage(named: "Purchase-Gold"), buttonText: "£2.99") { () -> Void in

        }

        let purchaseVC = OnboardingViewController(backgroundImage: nil, contents: [welcomePage, firstPurchasePage, secondPurchasePage, thirdPurchasePage])

        return purchaseVC
    }
}

我希望这就是你想要的


上的演示中,我添加了这个

override func viewWillAppear(animated: Bool) {

    self.view.addSubview(generatePurchasePaging().view)
}

这只是显示第一页不允许您在将其添加到ViewController属性时滚动到多个页面这不是我要求的,我希望它可以滚动到下面的按钮来指示这一点,您发布的代码用户需要按下按钮才能移动到下一页…好的,我想你只是想知道如何在自定义viewController上使用Board,我将继续你想要的。我想复制github自述页面上显示的示例。我编辑了代码,但此更改有一个缺点,你的自定义viewController将不再链接到主故事板,因为我不得不用backgroundimage:contents:intheinit?coder-aDecoder:nscoder救了我的命,他们真的有一个糟糕的文档,这对你有用吗?在我的例子中,它确实添加了它,但随后的加载是不可用的
override func viewWillAppear(animated: Bool) {

    self.view.addSubview(generatePurchasePaging().view)
}