ios - 无法执行自动转场

标签 ios iphone swift segue

我是 iOS 开发新手,我正在尝试在 Storyboard 之间切换。

我按照这里提供的答案 'Receiver (<ViewController>) has no segue with identifier 'addSegue' .

我做了每一步并将下面的代码放在我的 viewDidLoad 中,因为我希望它自动转到一个新的 Storyboard,而不取决于任何条件。我做错了什么吗?

self.performSegue(withIdentifier: "identifierName", sender: self)

最佳答案

您的代码是用 prepareForSegue 方法编写的

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

    if(segue.identifier == "yourIdentifierInStoryboard")
{
self.performSegue(withIdentifier: "identifierName", sender: self)
}
}

关于ios - 无法执行自动转场,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44305632/

相关文章:

ios - 如何在 iPad 中创建 Popover?

iphone - UIView动画取消之前的动画?

swift - 为什么在 Swift 中使用 new() 类方法创建对象无法编译?

ios - 将 UITextView 限制为 1 行并动态更改宽度

iphone - FFMpeg 编码不适用于 iPhone 3g 但 iPhone 4 运行良好

swift - UILabel 的内容在 Swift 4 中旋转后被截断

ios - swift 3 : Type 'Any?' has no subscript members

iphone - CGContextSaveGState 无效上下文

ios - 在 Alamofire 的请求适配器中添加 GET 参数

iphone - UIImage 操作需要帮助