我正在使用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)
委托:
extension MyController: UIAdaptivePresentationControllerDelegate {
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}
}
使用modalPresentationStyle = .pageSheet时出现了同样的问题。在其他modalPresentationStyles(如全屏)下正常工作。
这是在iOS 12.1,swift 3上的情况。
有什么解决办法吗?谢谢。