gpt4 book ai didi

ios - performSegueWithIdentifier 没有带有标识符的 segue

转载 作者:IT王子 更新时间:2023-10-29 05:09:53 26 4
gpt4 key购买 nike

我在测试我的应用程序时遇到了崩溃。下图是我的 Storyboard:

storyboard

我在 View Controller 中有代码:

@IBAction func unwindToHomeScreen(segue:UIStoryboardSegue) {

}

“添加新项目” View 有一个“取消”按钮,我将其控制拖动到顶部的“退出”图标并链接到 unwindToHomeScreen,它工作正常。

“添加新项”有一个类 AddTableViewController 和我在里面写的代码:

@IBAction func save() {
// Execute the unwind segue and go back to the home screen
performSegueWithIdentifier("unwindToHomeScreen", sender: self)
}

我控制拖动“保存”按钮到函数,但当我单击该按钮时应用程序崩溃

我可以使用 dismissViewControllerAnimated(true, completion: nil) 代替,但我只是想知道为什么 performSegueWithIdentifier 不能工作?

我在 dropbox.com/s/hpybgg9x67rtqng/foodpinstatictable.zip?dl=0 阅读了代码并尝试制作一个并像这个示例一样使用 performSegueWithIdentifier 进行练习,我没有看到她的 segue 标识符,有什么区别?

最佳答案

你实际上并没有给那个 segue 一个标识符。 unwindToHomeScreen 是一个你可以调用的函数;您正在寻找的是您的 segue 标识符,它在 Interface Builder 中设置如下:

Set an identifier

在这个例子中,我有一个按钮通过 Interface Builder 连接到下一个 View ,就像你描述的那样(“Interface Builder”),还有一个按钮连接到我的 View Controller 中的这个 IBAction(“以编程方式”):

@IBAction func goToNextView(sender: UIButton!) {
self.performSegueWithIdentifier:("go", sender: self)
}

无论如何,您缺少的是实际标识符,它可以在 Interface Builder 中创建的 segue 的属性中设置。

关于ios - performSegueWithIdentifier 没有带有标识符的 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27889645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com