swift - 如何在Xcode 11.1中创建使 View Controller 全屏显示的Segue

标签 swift xcode segue

当我尝试通过 Storyboard 创建segue时,只会弹出新 View Controller ,而不是全屏显示。我尝试将“,Show(例如Push)”的segue类型更改为其他类型,但随后出现“Thread 1:signal SIGABRT”

最佳答案

您需要做的是通过modalPresentationStyle将目标 View Controller 的fullscreen设置为prepareForSegue:sender::

class FirstViewController: UIViewController {

    ...

    @IBAction func segueButtonPressed(_ sender: Any) {
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        super.prepare(for: segue, sender: sender)

        if let secondViewController = segue.destination as? SecondViewController {
            secondViewController.modalPresentationStyle = .fullScreen
        }
    }
}

在从prepareForSegue:sender:执行序列之前,先调用UIViewController。 iOS 13+中的默认modalPresentationStyle.pageSheet,这是并没有覆盖整个屏幕的演示(尽管通过上下滑动 View Controller 可以实现更自然的导航/关闭)。在执行segue之前,我们需要将此modalPresentationStyle更改为.fullScreen

关于swift - 如何在Xcode 11.1中创建使 View Controller 全屏显示的Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58507034/

相关文章:

iOS:popToRootViewControllerAnimated 后跟 performSegue 不起作用

ios - bool 值的奇怪控制台输出

swift - UISearchController 中的取消按钮在 iOS 13 中没有正确消失

ios - “CGPointMake”在 swift 中不可用

objective-c - 隐藏在 Lion 中的滚动条。如果人们不使用触控板,他们如何水平滚动?

ios - XCode7 : "Failed to render instance of" affects all UICollectionViewCells

xcode - 以编程方式在 Swift 3.0 中创建 NSImageView

objective-c - NSURLConnection 后查看 Controller Segue 延迟

ios - Segue 没有被转入(swift 3)

ios - 从函数返回数据 (Swift)