我想在我的 TableViewController
中选择一个单元格。单元格的文本应该通过 segue 传输到 FirstViewController 的标签。我总是收到如下所示的错误。
标识符正确。
我的代码:
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "BackToCalculator") {
//let myRow = tableView.indexPathForSelectedRow().row+1
let vc = segue.destinationViewController as FirstViewController
vc.SelectedBundesland.text = "Test"
}
}
异常(exception):
0x103f1f5dc: jne 0x103f1f5d0 ; swift_dynamicCastClassUnconditional + 48 0x103f1f5de: leaq 0x3364d(%rip), %rax ; "Swift dynamic cast failed" 0x103f1f5e5: movq %rax, 0xa456c(%rip) ; gCRAnnotations + 8 0x103f1f5ec: int3
0x103f1f5ed: movq %r14, %rax
怎么了?
最佳答案
可能在比赛中迟到了,但遇到了完全相同的问题。 这里的问题是您的 Segue 指向 Tab Controller ,而不是它需要跳转到的实际 ViewController。我指的是您提供给安东尼奥的第二张截图。如果你修复它应该可以正常工作。
关于ios - Swift:PrepareForSegue,Swift Cast 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25406309/