ios - 执行 Segue 在 iOS 10 中崩溃

标签 ios iphone swift xcode

我在 Xcode 8.2 beta 的 swift 2.3 中有一个项目,这个项目在 iOS < 10 中运行良好,但是当我运行 iOS 10 时,这个项目崩溃了,没有任何理由执行 segue。显示此错误:

fatal error :在展开可选值时意外发现 nil

这是代码行

NSOperationQueue.mainQueue().addOperationWithBlock {
     self.performSegueWithIdentifier("goToActivityDetail", sender: nil)
}

我不知道发生了什么,但我什至没有调用该方法

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

请帮帮我!我对 iOS 10 和 Swift 2.3 或 iOS 9.3 和 Swift 3 之间的兼容性感到绝望

最佳答案

Storyboard中存在您的转场“goToActivityDetail”吗?当您添加覆盖时,您正在设置 Controller 的类型?有些像这样:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "goToActivityDetail"{
            let v = segue.destinationViewController as! yourControllerName
        }
    }

关于ios - 执行 Segue 在 iOS 10 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41108024/

相关文章:

ios - 当 Cocos2D 2.0 支持 NPOT 纹理时,为什么要使用纹理图集?

ios - 动态改变TableView Cell高度

iphone - 如何在 ios 中进行函数调用等待,直到该函数内的 block 完全执行?

swift - 如何在 swift 中声明类型别名和枚举?

由于 IBOutlet,iOS 应用程序在 didFinishLaunchingWithOptions 中崩溃

iPhone : How to display multiple colors in progress bar?

ios - 如何获取单元格的页脚单元格中的总数?

iphone - swift 中的类型有问题吗?

iPhone:如何在自定义单元格的动态数量上管理 UITextfield 委托(delegate)方法

ios - 在 Swift 中将 UITableView delegate 和 dataSource 分配给 super