iPhone XR,XS Max上的modalPresentationStyle formSheet问题

van*_*dzi 5 ios ios-autolayout

我正在使用modalPresentationStyle = .formSheet显示模式UIViewController,但是在iPhone XR和XS Max上存在一些问题。显示在缺口的后面。左侧iPhone XR,XS,X的图像波纹管

在此处输入图片说明

UIViewController使用自动布局,并且显示如下:

let contentViewController = UINib(nibName: "EditViewController", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! EditViewController

let navController = UINavigationController(rootViewController: contentViewController)

navController.modalPresentationStyle = UIModalPresentationStyle.formSheet
let popover = navController.presentationController!
popover.delegate = self

self.present(navController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

代表:

extension MyController: UIAdaptivePresentationControllerDelegate {

    func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
        return .none
    }
}
Run Code Online (Sandbox Code Playgroud)

modalPresentationStyle = .pageSheet也存在相同的问题。它可以与其他modalPresentationStyles(即全屏)一起使用

在iOS 12.1和Swift 3上

任何想法如何解决这个问题?谢谢

Gaé*_*anZ 1

UIKit 不支持这一点。

唯一的可能性是sheet to full screenpage sheet to form sheetiPad 上。如文档中所述:

在水平紧凑的环境中,此选项的行为与 UIModalPresentationFullScreen 相同。

所以 UIKit 已经适应了它。

不幸的是,您必须实现自己的自定义转换控制器。