我正在尝试使用开源框架iOS BWWWalkthroughController (链接:https://github.com/ariok/BWWalkthrough)为我的BWWWalkthroughController应用程序创建一个自定义演练,但我无法让它工作!
下面是发生错误的类:
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)让演练= 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中都有正确的名称,而且我确信所有的类都是正确链接的(插座、操作等等)。(我也看过许多相似的问题,没有答案。)有什么问题吗?谢谢!
发布于 2015-06-29 10:02:54
问题可能是Xcode中的一个bug --我的“was”视图控制器属于IB中的BWWalkthroughViewController类,但Xcode一直告诉我并非如此。最后,我删除了视图控制器,并做了一个新的,这是有效的。
https://stackoverflow.com/questions/31105449
复制相似问题