ios - Swift:PrepareForSegue,Swift Cast 失败

标签 ios xcode uitableview swift

我想在我的 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/

相关文章:

ios - 制作像回旋镖一样的视频循环效果

uitableview - 解析后端和 Swift UITableview

ios - UISegmentedControl filter Table View data JSON 错误

ios - 如何在 ios 中通过 http get 请求在控制台中显示数据

iphone - MPMoviePlayerViewController 从 Documents 目录播放电影 - objective-c

ios - 在 Storyboard中更改 UIImageView 的大小

ios - 在 iOS7 中滚动之前,uitableviewcell 不会更新

ios - 在每次翻页 UIPageViewController 后调用方法调用

swift - XCTest:在所有平台(Xcode、SPM Mac/Linux)上不使用 Bundle 从磁盘加载文件

ios - 错误 : UITableViewController loaded the "TableViewController" nib but didn't get a UITableView HOWEVER I've already deleted the NIB file