小弟最近在开发IOS应用,却发现一个问题,IOS7和IOS8在横屏模式下得到的宽高是不一样的,竖屏是一样的,但是在网上却没有找到类似的解决方法,于是自己写了一个方法,如要使用,直接粘贴到viewcontroller即可
/*
根据系统版本号得到真实的宽高
isWidth是YES,那么代表得到宽度,是NO代表得到高度
*/
-(float) getTrueWidthOrHeight:(BOOL) isWidth{
//得到屏幕的大小
CGRect myRect=[UIScreen mainScreen].bounds;
float length=0.0f;
//得到系统版本号
double version = [[UIDevice currentDevice].systemVersion doubleValue];
//如果系统版本号小于8.0f,即是7.X或以下,且还是横屏
if(version<8.0f&&(self.interfaceOrientation==UIDeviceOrientationLandscapeRight||self.interfaceOrientation==UIDeviceOrientationLandscapeLeft)){
//那么要得到的宽高要反过来
if (isWidth) {
length =myRect.size.height;
}
else{
length=myRect.size.width;
}
}
else{
if (isWidth) {
length=myRec