手元でiPhone XS Max(iOS12.1)のシミュレーターでポップオーバーを表示してみましたが、特にはみ出すようなことはありませんでした。
検証コードはSwiftです。
swift
1import UIKit
2
3class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
4
5 override func viewDidLoad() {
6 super.viewDidLoad()
7
8 let btn = UIButton(type: .system)
9 btn.frame = CGRect(x: 20, y: 40, width: 100, height: 44)
10 view.addSubview(btn)
11 btn.layer.borderColor = UIColor.black.cgColor
12 btn.layer.borderWidth = 1
13 btn.setTitle("test", for: .normal)
14 btn.addTarget(self, action: #selector(test), for: .touchUpInside)
15 }
16
17 @objc private func test(_ sender: UIButton) {
18 let vc = PopupViewController()
19
20 let navi = UINavigationController(rootViewController: vc)
21 navi.modalPresentationStyle = .popover
22 navi.preferredContentSize = CGSize(width: 150, height: 100)
23
24 if let presentationController = navi.popoverPresentationController {
25 presentationController.permittedArrowDirections = .any
26 presentationController.sourceRect = sender.bounds
27 presentationController.sourceView = sender
28 presentationController.delegate = self
29 }
30
31 present(navi, animated: true, completion: nil)
32 }
33
34 func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
35 return .none
36 }
37}
38
39class PopupViewController: UIViewController {
40 override func loadView() {
41 super.loadView()
42 view.backgroundColor = .red
43 title = "popover"
44 }
45}
実行結果:
画面サイズの高さが414を超える端末で
これって画面サイズの高さではなく幅の事を言っているんだと思いますが、
画面を横向きで実行しているんでしょうかね?
追記:
上記コードでは画面横のときにポップオーバーではなくモーダルで出てしまうようです。
UIAdaptivePresentationControllerDelegate
プロトコルの以下を実装すると、横向きでもちゃんと出るようです。
swift:
1 func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
2 return .none
3 }
実行結果: