原文  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. 使用ssh公钥密钥自动登陆linux服务器

    转自:http://7056824.blog.51cto.com/69854/403669 作为一名 linux 管理员,在多台 Linux 服务器上登陆进行远程操作是每天工作的一部分.但随着服务器的 ...

  2. li添加浮动时不能完全包裹的方法

    <html> <head> <meta http-equiv="Content-Type" content="text/html;chars ...

  3. HDU 3844 Mining Your Own Business(割点,经典)

    题意: 给出一个连通图,要求将某些点涂黑,使得无论哪个点(包括相关的边)撤掉后能够成功使得剩下的所有点能够到达任意一个涂黑的点,颜料不多,涂黑的点越少越好,并输出要涂几个点和有多少种涂法. 思路: 要 ...

  4. Mybatis学习——一对多关联表查询

    1.实体类 public class Student { private int id; private String name; } public class Classes { private i ...

  5. NYOJ-779-兰州烧饼

    [题目链接:NYOJ-779] 兰州烧饼 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 烧饼有两面,要做好一个兰州烧饼,要两面都弄热.当然,一次只能弄一个的话,效率 ...

  6. 使用solrj操作solr索引库

    (solrj)初次使用solr的开发人员总是很郁闷,不知道如何去操作solr索引库,以为只能用<五分钟solr4.5教程(搭建.运行)>中讲到的用xml文件的形式提交数据到索引库,其实没有 ...

  7. K2 blackpearl 安装

    转:http://blog.csdn.net/gxiangzi/article/details/8432188 K2是国外的一款BPM引擎,基于MS的Workflow,关于它的详细介绍在我之前一片博客 ...

  8. 解决WCF大数据量传输 ,System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接

    开发中所用的数据需要通过WCF进行数据传输,结果就遇到了WCF大量传输问题 也就是提示System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接 网上解决 ...

  9. GCC 编译优化指南

    转自: http://www.jinbuguo.com/linux/optimize_guide.html GCC 编译优化指南 作者:金步国[www.jinbuguo.com] 版权声明 本文作者是 ...

  10. 【转】AVL

    #include <iostream> #include <ctime> #include <queue> #include <cassert> #in ...