繁体   English   中英

在Swift for iOS中使用BWWWalkthroughController进行转换错误

[英]Casting error using BWWWalkthroughController in Swift for iOS

我正在尝试使用开源框架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中正确命名,并且我确信所有课程都正确链接(插座,操作等)(我已经查看了许多类似的问题,没有任何答案适合我。想法可能是什么问题?谢谢!

问题可能是Xcode中的一个错误 - 我的“walk”视图控制器是IB中的BWWalkthroughViewController类,但是Xcode不断告诉我。 我最终删除了视图控制器并创建了一个新的视图控制器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM