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

What is the height of the modalPresentationStyle - FormSheet on iPad? I wrote a line of code to get the height of self.view as follows:

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

I got these two results after testing:

No form on ModalViewController , height 1,024.0

With a sheet in modalPresentationStyle , the height is 1024.0 , which is not true since the height should be less than 1024.0

Any idea what's wrong with that? I need to get the correct height from self.view.frame.size.height with the form sheet, because I need to write the formula somewhere in the code. I do not need to resize the sheet.

+2
source share
1 answer

Do not viewDidLoad your println inside viewDidLoad , but inside viewDidAppear .

The following class, presented on the Storyboard using Segue: Present Modally and Presentation: Form Sheet gives different results for the same println when calling viewDidLoad , viewWillAppear or viewDidAppear :

 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 } } 
+4
source

Source: https://habr.com/ru/post/891435/


All Articles