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

Xcode11中iPad从视图控制器A跳转至B时B无法全屏显示

解决iPad上Segue转场后视图控制器B非全屏的问题

这个问题其实是iOS 13+引入的模态呈现样式变化导致的——iPad上默认的模态呈现样式是UIModalPresentationStyle.pageSheet(就是你看到的小方形窗口),而你勾选的Use Full Screen (deprecated)是旧版iOS的设置,在新系统里优先级更低,所以没起作用。下面给你几个靠谱的解决办法:

方法1:在Storyboard里修改Segue的Presentation设置

  • 打开你的Storyboard,找到从A到B的Segue线,点击选中它
  • 打开右侧的Attributes Inspector(属性检查器)
  • 在Presentation下拉菜单里,选择Full Screen(注意不是那个带deprecated标记的选项,是单独的Full Screen)
  • 这样设置后,不管是iPhone还是iPad,转场到B都会全屏显示

方法2:直接设置视图控制器B的默认呈现样式

  • 选中Storyboard里的视图控制器B
  • 在Attributes Inspector里找到Presentation选项,设置为Full Screen
  • 这个方法更彻底,不管从哪个Segue跳转到B,都会默认全屏呈现

方法3:用代码强制设置(适合动态控制的场景)

如果你的Segue是通过代码触发的,或者需要根据条件动态调整,可以在视图控制器A的prepare(for:sender:)方法里添加代码:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "YourSegueIdentifier" {
        let destinationVC = segue.destination
        destinationVC.modalPresentationStyle = .fullScreen
    }
}

(如果是Objective-C的话,代码如下)

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"YourSegueIdentifier"]) {
        UIViewController *destinationVC = segue.destinationViewController;
        destinationVC.modalPresentationStyle = UIModalPresentationFullScreen;
    }
}

补充说明

为什么Use Full Screen (deprecated)没用?因为这个选项是iOS 12及更早版本的设置,iOS13之后苹果推出了新的模态呈现体系(包括pageSheet、formSheet、fullScreen等),旧的deprecated选项会被新的Presentation设置覆盖,所以即使勾选了,iPad上还是会用默认的pageSheet样式。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 15:17:58