[英]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.