In ViewController.m
, on an iPad, if we print out the view's frame height in a tap event handler:
NSLog(@"Height of main view is %f", self.view.frame.size.height);
then in Portrait mode, the value is 1004 (20 pixel for device status line, so 1024 - 20 = 1004), and if the device is rotated to Landscape mode, I expected it to be about 768 or 748, but the value printed is actually 1024. (update: if the app is started in Landscape mode, then without rotation, it is also printed as 1024). Why would that be, and is there a rule of thumb to expect getting the value of 748 or 768? (Is there more than one way to get that?)
In Apple's documents, about UIView's frame:
Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
So you should use bounds property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With