我已经使用此代码来获取屏幕宽度和屏幕高度,
float scaleFactor = [[UIScreen mainScreen] scale];
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat widthInPixel = screen.size.width * scaleFactor;
CGFloat heightInPixel = screen.size.height * scaleFactor;
NSLog(@"%f",widthInPixel);
NSLog(@"%f",heightInPixel);
和
CGRect screenBounds = [[UIScreen mainScreen] bounds];
NSLog(@"screenBounds W %f",screenBounds.size.width);
NSLog(@"screenBounds H %f",screenBounds.size.height);
但它在纵向和横向模式下显示相同的宽度 = 768 和高度 = 1024..