gpt4 book ai didi

swift - 使用板载设置 View Controller

转载 作者:可可西里 更新时间:2023-11-01 00:52:09 28 4
gpt4 key购买 nike

嘿,伙计们,我目前正在使用板载库,如果您不知道的话,这里有一个链接 https://github.com/mamaral/Onboard

问题是我试图在我的 View Controller 中而不是在应用程序委托(delegate)中使用它,如示例中所示,它使用以下代码来设置 View Controller 。

self.window.rootViewController = self.generateSecondDemoVC()

但我似乎无法在我的 View Controller 中执行此操作,因为没有此选项并且它没有编译,我如何将 View Controller 设置为返回 OnboardingViewController 的方法?

这是我的 View Controller 文件

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

最佳答案

希望这就是你想要的

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 上的演示

关于swift - 使用板载设置 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34277265/

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