iPad 上的 modalPresentationStyle - FormSheet 的高度究竟是多少?

What exactly is the height of modalPresentationStyle - FormSheet on iPad?

iPad 上的 modalPresentationStyle - FormSheet 的高度究竟是多少?我写了一行代码来获取 self.view 的高度,如下所示:

println("Height - modalPresentationStyle FormSheet: \(self.view.frame.size.height)")

测试后得到这两个结果:

ModalViewController 上没有 Formsheet,高度为 1024.0

Formsheet on modalPresentationStyle,高度为 1024.0 这是错误的,因为高度应该小于 1024.0

知道它有什么问题吗?我需要使用表单从 self.view.frame.size.height 获得正确的高度,因为我需要在代码中的某处编写公式。我不需要更改表单的大小。

不要在 viewDidLoad 内实施您的 println,而是在 viewDidAppear.

内实施

故事板中呈现的以下 class Segue:模态呈现呈现:形式 SheetviewDidLoadviewWillAppearviewDidAppear 中调用相同的 println 时给出不同的结果:

class ViewController2: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        println(view.frame) // (0.0, 0.0, 768.0, 1024.0)
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        println(view.frame) // (0.0, 0.0, 768.0, 1024.0)
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        println(view.frame) // (0.0, 0.0, 540.0, 620.0) // Correct values
    }

}