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

标签 ios xcode swift casting bwwalkthrough

我正在尝试使用开源框架 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/

相关文章:

ios - 社交媒体应用程序的最佳压缩质量?

ios - 如何从使用结构创建的数组中追加一个项目?

ios - 将存档的应用程序上传到 iTunes Connect 时出现错误 ITMS-90085

swift - 无法将 [NSObject] 类型的值分配给 NSObject 类型

ios - Swift:我的自定义 UITableViewDataSource 类认为它不符合协议(protocol) 'UITableViewDataSource'

ios - SFSpeechRecognizer 识别几个命令词而不是整个短语?

ios - 迭代数组时,TableViewcells 不会出现在 tableView 中。 iOS 版

ios - 我如何创建一个使用 CCSpriteFrameCache 和 CCSpriteBatchNode 对象的 CSSprite 类?

ios - 如何获取多点触控UITapGestureRecognizer的多个位置

xcode - Sigabrt swift Xcode(制作计时器)