如何摆脱或更改故事板以编程方式创建 segue

How to get rid of or change a storyboard created segue programatically

我有一个从一个视图控制器到另一个视图控制器的 segue,它是在我的项目的故事板中创建的。我想知道是否有办法通过代码更改或摆脱该 segue。谢谢,使用 Xcode 9 Swift 4.

显然这是不可能的...看看 this post. And the documentation 上的答案说的是关于创建 segues 的:

"You do not create segue objects directly. Instead, the storyboard runtime creates them when it must perform a segue between two view controllers."

虽然不是改删segue,但我觉得是一样的道理

如果你只是想避免 segue 发生,你可以在 "shouldPerformSegue" 中这样做(就像评论中的 vacawama 所说):

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { 
    if identifier == "aSegueIWantToDisable" { 
        return false 
    } 
    return true 
}