3

我正在尝试使用开源框架 BWWalkthroughController(链接: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") as!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 中都正确命名,并且我很确定一切都正确链接(出口、操作等)(我查看了许多看起来相似的问题,但没有对我有用的答案。任何想法可能是什么问题?谢谢!

4

1 回答 1

3

问题可能是 Xcode 中的一个错误——我的“walk”视图控制器属于 IB 中的 BWWalkthroughViewController 类,但 Xcode 一直告诉我不然。我最终删除了视图控制器并制作了一个新的,这很有效。

于 2015-06-29T10:02:54.273 回答