我試圖實現navegationController編程viewcontrollers之間進行切換:的iOS:無法投類型NextViewContrller的價值UINavigationController的
@IBAction func next(_ sender: Any) {
self.performSegue(withIdentifier: "next", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "next"{
let destNVC = segue.destination as! UINavigationController
let next = destNVC.topViewController as! NextViewController
next.title = "next!"
}
}
但我發現了這個錯誤:
Could not cast value of type 'myProject.NextViewController' (0x108de5338) to 'UINavigationController' (0x10aa2d4a8).
你們誰都知道我爲什麼會遇到這個錯誤?
我真的很感謝你的幫助。