2015-12-14 30 views
2

嗨所以我目前使用這裏的板載庫是一個鏈接,如果你不知道它https://github.com/mamaral/Onboard建立一個視圖控制器,板載

的問題是,我想在我的視圖控制器使用此而不是在應用程序委託中,如示例所示,這是使用以下代碼來設置視圖控制器。

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 
    } 
} 

回答

1

我想通了,加入這個

override func viewWillAppear(animated: Bool) { 

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

拯救了我的生命,他們確實有一份糟糕的文檔 –

+0

這是否仍適用於您?在我的情況下,它確實添加了它,但是隨後的登錄無法使用 –

1

我希望這是你想要

class ViewController: OnboardingViewController { 

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { 
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 
    } 

    required init?(coder aDecoder: NSCoder) { 

    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: "") {} 
    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") {} 
    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") {} 
    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") {} 

    super.init(backgroundImage: nil, contents: [welcomePage, firstPurchasePage, secondPurchasePage, thirdPurchasePage]) 

    // Customize Onboard viewController 
    allowSkipping = true 
    skipHandler = { print("Skip") } 

    } 

    override func viewDidLoad() { 
    super.viewDidLoad() 
    view.backgroundColor = UIColor.yellowColor() 
    } 

} 

演示上Github

+0

這只是顯示第一頁不允許您滾動到多個頁面,當您將其添加到viewControllers屬性 – Tunds

+0

現在呢? –

+0

這不是我所要求的,我希望它可以滾動按鈕來指示下面,您發佈用戶的代碼將需要按下按鈕移動到下一頁.... – Tunds

相關問題