[英]Modal UIViewController with presentation style formSheet is not displayed correctly on iPhone XS Max and iPhone XR
[英]modalPresentationStyle formSheet issues on iphone XR, XS Max
我正在使用modalPresentationStyle = .formSheet顯示模態UIViewController,但它在iphone XR和XS Max上有一些問題。 它顯示在缺口之后。 圖像左側是iphone XR,XS,X。
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 page sheet to form sheet
sheet to full screen
和page sheet to form sheet
。 如文檔中所述:
在水平緊湊的環境中,此選項與UIModalPresentationFullScreen的行為相同。
所以UIKit已經適應了它。
不幸的是,您必須實現自己的自定義轉換控制器。
正如GaétanZ所說,更好地使用另一種模態演示樣式,如overFullScreen,用於緊湊的水平尺寸克拉,並將formSheet保留為水平常規格式。
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
if controller.traitCollection.horizontalSizeClass == .regular {
return .formSheet
}
return .overFullScreen
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.