原文  http://www.cnblogs.com/smileEvday/p/iOS8.html

 

1、UIWindow的bounds

iOS 7之前Window的bounds不会随着方向而变化,但是到了iOS 8以后,随着设备方向的旋转,window.bounds.size.width和window.bounds.size.height也会相应发生变化。

做个很简单的测试,代码如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil]; return YES;
} - (void)orientationChanged:(NSNotification*)noti { UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
NSString *orientationDes = nil;
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
orientationDes = @"UIInterfaceOrientationLandscapeRight";
break;
case UIDeviceOrientationLandscapeRight:
orientationDes = @"UIInterfaceOrientationLandscapeLeft";
break;
case UIDeviceOrientationPortrait:
orientationDes = @"UIInterfaceOrientationPortrait";
break;
case UIDeviceOrientationPortraitUpsideDown:
orientationDes = @"UIInterfaceOrientationPortraitUpsideDown";
break;
default:
orientationDes = @"";
break;
} NSLog(@"system ver: %@, \rorientaion: %@, \rwindow bounds: %@",
[UIDevice currentDevice].systemVersion,
orientationDes,
NSStringFromCGRect(self.window.bounds));
}

示例代码很简单,新建一个工程,然后在delegate中直接添加以上代码即可。

iOS 8上运行结果为:

-- ::32.016 SviOS8[:] system ver: 8.0,
orientaion: UIInterfaceOrientationLandscapeRight,
window bounds: {{, }, {, }}
-- ::34.788 SviOS8[:] system ver: 8.0,
orientaion: UIInterfaceOrientationPortrait,
window bounds: {{, }, {, }}
-- ::35.791 SviOS8[:] system ver: 8.0,
orientaion: UIInterfaceOrientationLandscapeLeft,
window bounds: {{, }, {, }}
-- ::47.468 SviOS8[:] system ver: 8.0,
orientaion: UIInterfaceOrientationPortraitUpsideDown,
window bounds: {{, }, {, }}

iOS 7及之前的版本运行结果为:

-- ::00.527 SviOS8[:70b] system ver: 7.0.,
orientaion: UIInterfaceOrientationLandscapeRight,
window bounds: {{, }, {, }}
-- ::00.895 SviOS8[:70b] system ver: 7.0.,
orientaion: UIInterfaceOrientationPortrait,
window bounds: {{, }, {, }}
-- ::01.225 SviOS8[:70b] system ver: 7.0.,
orientaion: UIInterfaceOrientationLandscapeLeft,
window bounds: {{, }, {, }}
-- ::11.004 SviOS8[:70b] system ver: 7.0.,
orientaion: UIInterfaceOrientationPortraitUpsideDown,
window bounds: {{, }, {, }}

通过对比我们可以清晰的看到iOS 8中UIWindow在处理旋转时策略的变更,虽然会因为与之前的版本不同导致现有项目布局存在的bug,但是可以看到iOS 8中的处理方式更加符合我们的预期,在竖向的时候我们就获取到width < height, 在横向则是 width > height,这个符合所见即所得的原则。

iOS 8版本信息与屏幕尺寸的更多相关文章

  1. iOS系统下 的手机屏幕尺寸 分辨率 及系统版本 总结

    今天  我对iOS系统下 的手机屏幕尺寸 分辨率 及系统版本做了一次系统总结 供大家参考. 首先 是系统:    随着iOS 系统不断升级,现在已经到iOS7.0了, 并且TA有了很多新变化,最震撼的 ...

  2. iOS 关于字体根据不同屏幕尺寸等比适配的问题(zz)

    http://www.jianshu.com/p/5815e81abb52 背景 去年的六月份开始了一个新的项目,此项目支持的设备从4S开始一直到6+,也就是说屏幕的尺寸最小的320x480 最大的1 ...

  3. [Swift通天遁地]五、高级扩展-(1)快速检测设备属性:版本、类型、屏幕尺寸

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. iOS屏幕尺寸和分辨率了解

    1.截至目前为止,主流的iOS设备屏幕有以下几种: ---------------  iPhone  ---------- --------  iPad ------------ 2.iOS设备屏幕分 ...

  5. IOS 判断设备屏幕尺寸、分辨率

    根据屏幕尺寸和分辨率,ios现在数起来有6个版本. iOS 设备现有的分辨率如下: iPhone/iPod Touch 普通屏 320像素 x 480像素 iPhone .3G.3GS,iPod To ...

  6. IOS 屏幕尺寸、分辨率、点之间的相互关系

    iOS 设备现有的分辨率如下:iPhone/iPod Touch普通屏                         320像素 x 480像素       iPhone 1.3G.3GS,iPod ...

  7. ios设备屏幕尺寸与分辨率

    iOS 设备的屏幕尺寸.分辨率及其屏幕边长比例详细情况是怎样的? 根据屏幕尺寸和分辨率,ios现在数起来有6个版本.一,3GS:二,4s为代表:三,iphone5:四,ipad2为代表:五,ipad4 ...

  8. iOS屏幕尺寸和分辨率

    iOS平台家族成员主要包括iPhone.iPod Touch和iPad,但是各类设备的分辨率各不相同,目前存在的尺寸主要有: iOS设备的尺寸多种多样,此外,屏幕的分辨率也有多种,总结如下表所示: 其 ...

  9. js网页判断移动终端浏览器版本信息是安卓还是苹果ios,判断在微信浏览器跳转不同页面,生成二维码

    一个二维码,扫描进入网页,自动识别下载苹果和安卓客户端,判断网页如下,(只有苹果的微信不能自动跳转)所以加个微信判断. <!DOCTYPE html> <html> <h ...

随机推荐

  1. n人比赛,可轮空,比赛轮数和场数

    #include<stdio.h> int chang(int x,int s){ ) return s; ) ; !=){ s+=(x-)/; )/,s); } else{ s+=x/; ...

  2. sublime-text3插件安装

    sublime-text3和sublime-text2一样安装插件前都需要先安装,Package control ,然而安装Package control的代码和sublime-text2又不相同.如 ...

  3. Ajax、Comet与Websocket

    从 http 协议说起 1996年IETF  HTTP工作组发布了HTTP协议的1.0版本 ,到现在普遍使用的版本1.1,HTTP协议经历了17 年的发展.这种分布式.无状态.基于TCP的请求/响应式 ...

  4. 注解框架ButterKnife

    将插件升级到1.3后支持Android Studio1.3 + ButterKnife7 如何使用 有所使用的布局 ID 上点击右键 (例如上图中的 R.layout.activity_setting ...

  5. Tomcat 映射虚拟目录

    设置虚拟目录映射一般有两种用途: (1)把整个web应用映射到tomcat中: 如一个testapp的web应用的路径是/opt/testapp,则通过虚拟目录映射可以将其映射到tomcat(weba ...

  6. 【C#学习笔记】类构造函数使用

    using System; namespace ConsoleApplication { class stu { private string name; private int age; publi ...

  7. crtmpserver流媒体服务器的介绍与搭建

    crtmpserver流媒体服务器的介绍与搭建 (2012-02-29 11:28) 标签:  crtmpserver  C++ RTMP Server  rtmp  Adobe FMS(Flash ...

  8. <十>面向对象分析之UML核心元素之关系

    关系        --->在UML中关系是非常重要的语义,它抽象出对象之间的联系,让对象构成特定的结构.        一,关联关系(association)

  9. Ejabberd源码解析前奏--配置

    一.基本配置     配置文件将在你第一次启动ejabberd时加载,从该文件中获得的内容将被解析并存储到内部的ejabberd数据库中,以后的配置将从数据库加载,并且任何配置文件里的命令都会被添加到 ...

  10. site

    http://blog.csdn.net/zgmzyr/article/details/7657126