【发布时间】:2018-04-12 03:33:00
【问题描述】:
我正在使用 Xcode 做一个项目。我有四个按钮,其中两个用于在视图之间传递数据,而另外两个用于在不传递任何数据的情况下跳转到另一个视图。前两个表现非常好,将数据传递到另一个视图。但是当我点击其余两个时,应用程序崩溃并说:
"2017-10-30 23:08:11.970500-0400 xxx[2557:65602] 无法转换值 'xxx.goalInfoViewController' (0x107f01580) 类型的 'xxx.IOViewController' (0x107f019a0)。”
代码如下:
@IBAction func monthlyIncomeAction(_ sender: Any) {
numberForSegue = 1
performSegue(withIdentifier: "outcomeSegue", sender: self)
}
@IBAction func MonthlyOutcomeAction(_ sender: Any) {
numberForSegue = 2
performSegue(withIdentifier: "incomeSegue", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: (Any)?) {
let ioController = segue.destination as! IOViewController
ioController.segueIndex = numberForSegue
}
【问题讨论】:
-
你能告诉我当前控制器的类别是什么,2个目的地控制器的类别是什么?
-
@trungduc 你是说类的名字吗?
-
是的)。 UIViewController 类的名称
-
@trungduc 当前类是:"askForPlanViewController",2 个目的地类是一样的:"IOViewController"
-
goalInfoViewController类是什么?你在哪里使用它?
标签: swift xcode button segue pass-data