You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xcode中Storyboard无法识别自定义segue标识符,unwind segue调用失败

问题解决:Unwind Segue调用报错"Cannot find 'SaveData' in scope"

核心错误修正

你调用performSegue时犯了基础语法错误:标识符SaveData没有加双引号。withIdentifier参数要求传入字符串字面量,正确写法应为:

performSegue(withIdentifier: "SaveData", sender: self)

额外检查项(确保整个Unwind流程正常)

  • 确认FirstVC中已正确定义unwind方法,格式必须如下(参数为UIStoryboardSegue,且标记为@IBAction):
    @IBAction func unwindToFirstVC(_ segue: UIStoryboardSegue) {
        // 可在此处理返回时的数据传递等逻辑
    }
    
  • 检查Storyboard中segue的标识符是否完全匹配"SaveData",Xcode对标识符大小写敏感,需和代码里的字符串完全一致。
  • 确保performSegue的调用代码写在SecondVC的类文件中,因为这个unwind segue属于SecondVC场景。

内容的提问来源于stack exchange,提问作者Rayce Miller

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 13:50:32