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

为何创建普通Segue跳转ViewController时,在leagueVC中无法全屏显示?

解决Segue跳转ViewController无法全屏的问题

方法一:通过Storyboard可视化设置

  • 选中你创建的Segue,打开右侧的Attributes Inspector面板
  • 将Segue的类型从默认的Show改为Present Modally
  • 在Presentation下拉选项里选择Full Screen,这样跳转后的ViewController就会全屏展示
  • 若需要关闭全屏界面,在目标ViewController里给按钮添加点击事件,调用代码:self.dismiss(animated: true)

方法二:通过代码动态设置

  1. 先给Segue设置一个唯一的Identifier(比如toFullScreenVC),在Storyboard的Segue属性里完成配置
  2. 在leagueVC中重写prepare(for:sender:)方法:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    guard segue.identifier == "toFullScreenVC" else { return }
    let destVC = segue.destination
    destVC.modalPresentationStyle = .fullScreen
}
  1. 也可以直接用代码触发全屏跳转(无需依赖Storyboard Segue):
// 替换成你的目标ViewController的标识符
if let targetVC = storyboard?.instantiateViewController(withIdentifier: "TargetVC") {
    targetVC.modalPresentationStyle = .fullScreen
    present(targetVC, animated: true)
}

内容的提问来源于stack exchange,提问作者Ameer AG

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 13:27:25