gpt4 book ai didi

ios - 在 Swift for iOS 中使用 BWWWalkthroughController 的转换错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:35:06 25 4
gpt4 key购买 nike

我正在尝试使用开源框架 BWWWalkthroughController(链接:https://github.com/ariok/BWWalkthrough)为我的 iOS 应用程序创建自定义演练,但我无法让它工作!

这是发生错误的类:

import UIKit

class StartPageViewController: UIViewController, BWWalkthroughViewControllerDelegate {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

let userDefaults = NSUserDefaults.standardUserDefaults()

if !userDefaults.boolForKey("walkthroughPresented") {

showWalkthrough()

userDefaults.setBool(true, forKey: "walkthroughPresented")
userDefaults.synchronize()
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

@IBAction func showWalkthrough(){

// Get view controllers and build the walkthrough
let stb = UIStoryboard(name: "Walkthrough", bundle: nil)

让 walkthrough = stb.instantiateViewControllerWithIdentifier("walk") 作为! BWWalkthroughViewController <----- 这就是错误发生的地方

    let page_zero = stb.instantiateViewControllerWithIdentifier("walk0") as! UIViewController
let page_one = stb.instantiateViewControllerWithIdentifier("walk1") as! UIViewController
let page_two = stb.instantiateViewControllerWithIdentifier("walk2")as! UIViewController

// Attach the pages to the master
walkthrough.delegate = self
walkthrough.addViewController(page_one)
walkthrough.addViewController(page_two)
walkthrough.addViewController(page_zero)

self.presentViewController(walkthrough, animated: true, completion: nil)
}


// MARK: - Walkthrough delegate -

func walkthroughPageDidChange(pageNumber: Int) {
println("Current Page \(pageNumber)")
}

func walkthroughCloseButtonPressed() {
self.dismissViewControllerAnimated(true, completion: nil)
}

}

这是我的错误:

2015-06-29 00:24:02.951 Up & Down - Minimalistic, Beautiful Counter[13041:715011] Unknown class _TtC43Up & Down - Minimalistic, Beautiful Counter27BWWalkthroughViewController in Interface Builder file.
Could not cast value of type 'UIViewController' (0x10570c418) to 'Up___Down___Minimalistic__Beautiful_Counter.BWWalkthroughViewController' (0x103972fb0).
(lldb)

我已确保所有类在 IB 中都正确命名,并且我非常确定所有内容都已正确链接( socket 、操作等)(我看过许多看起来相似的问题,但没有答案适用于我。知道问题可能是什么吗?谢谢!

最佳答案

问题可能是 Xcode 中的错误 - 我的“行走” View Controller 属于 IB 中的 BWWalkthroughViewController 类,但 Xcode 一直告诉我不是这样。我最终删除了 View Controller 并制作了一个新的,效果很好。

关于ios - 在 Swift for iOS 中使用 BWWWalkthroughController 的转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31105449/

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