横向模式的高度和宽度显示错误 [英] Height and width for landscape mode is showing wrong

查看:101
本文介绍了横向模式的高度和宽度显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用这种方法来检测屏幕的宽度和高度.但是它在纵向和横向上也显示为768宽度和高度为1024.

I have used this method for detecting the width and height of screen. But its showing the width as 768 and height as 1024 in portrait and landscape also.

CGRect screenBounds = [[UIScreen mainScreen] bounds]; 

float widthfloat=  screenBounds.size.width;
float heightfloat= screenBounds.size.height;

NSLog(@"  width float %f",widthfloat);
NSLog(@"height float %f",heightfloat);


NSLog(@"width view %f \n height view %f", self.view.bounds.size.width, self.view.bounds.size.height);
NSLog(@"width %f \n height %f", screenBounds.size.width, screenBounds.size.height);


float wvalue  = [[UIScreen mainScreen] bounds].size.width;

float hvalue =  [[UIScreen mainScreen] bounds].size.height;


NSLog(@"  wvalue %f",wvalue);
NSLog(@"hvalue %f",hvalue);


CGFloat width1 = [UIScreen mainScreen].bounds.size.width;
CGFloat height1 = [UIScreen mainScreen].bounds.size.height;


NSLog(@"width1 %f",width1);
NSLog(@"height1 %f",height1);

CGFloat screenScale = [[UIScreen mainScreen] scale];

CGRect screenBounds1 = [[UIScreen mainScreen] bounds];

CGSize screenSize = CGSizeMake(screenBounds1.size.width * screenScale, screenBounds1.size.height * screenScale); if (screenSize.height==1136.000000)

NSLog(@"abcd1 %f",screenBounds1.size.width);
NSLog(@"abcd2 %f",screenBounds1.size.height);
NSLog(@"efgh1 %f",screenSize.width);
NSLog(@"efgh2 %f",screenSize.height);

推荐答案

边界包含屏幕的边界矩形,以点为单位.它不在乎屏幕方向.

bounds contains the bounding rectangle of the screen, measured in points. It does not care about screen orientation.

这篇关于横向模式的高度和宽度显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆