ios – iphone XR,XS Max上的modalPresentationStyle formSheet问题

我正在使用modalPresentationStyle = .formSheet显示模态UIViewController,但它在
iphone XR和XS Max上有一些问题.它显示在缺口之后.图像左侧是iphone XR,XS,X.

《ios – iphone XR,XS Max上的modalPresentationStyle formSheet问题》

UIViewController使用autolayout,如下所示:

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)

代表:

extension MyController: UIAdaptivePresentationControllerDelegate {

    func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
        return .none
    }
}

modalPresentationStyle = .pageSheet也存在同样的问题.它适用于其他modalPresentationStyles,即全屏

它在iOS 12.1上,swift 3

知道如何解决这个问题吗?谢谢

最佳答案 UIKit不支持这一点.

唯一的可能性是在iPad上使用工作表到全屏和页面到表单.如文档中所述:

In a horizontally compact environment, this option behaves the same as UIModalPresentationFullScreen.

所以UIKit已经适应了它.

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

点赞