iOS 8版本信息与屏幕尺寸
原文 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版本信息与屏幕尺寸的更多相关文章
- iOS系统下 的手机屏幕尺寸 分辨率 及系统版本 总结
今天 我对iOS系统下 的手机屏幕尺寸 分辨率 及系统版本做了一次系统总结 供大家参考. 首先 是系统: 随着iOS 系统不断升级,现在已经到iOS7.0了, 并且TA有了很多新变化,最震撼的 ...
- iOS 关于字体根据不同屏幕尺寸等比适配的问题(zz)
http://www.jianshu.com/p/5815e81abb52 背景 去年的六月份开始了一个新的项目,此项目支持的设备从4S开始一直到6+,也就是说屏幕的尺寸最小的320x480 最大的1 ...
- [Swift通天遁地]五、高级扩展-(1)快速检测设备属性:版本、类型、屏幕尺寸
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- iOS屏幕尺寸和分辨率了解
1.截至目前为止,主流的iOS设备屏幕有以下几种: --------------- iPhone ---------- -------- iPad ------------ 2.iOS设备屏幕分 ...
- IOS 判断设备屏幕尺寸、分辨率
根据屏幕尺寸和分辨率,ios现在数起来有6个版本. iOS 设备现有的分辨率如下: iPhone/iPod Touch 普通屏 320像素 x 480像素 iPhone .3G.3GS,iPod To ...
- IOS 屏幕尺寸、分辨率、点之间的相互关系
iOS 设备现有的分辨率如下:iPhone/iPod Touch普通屏 320像素 x 480像素 iPhone 1.3G.3GS,iPod ...
- ios设备屏幕尺寸与分辨率
iOS 设备的屏幕尺寸.分辨率及其屏幕边长比例详细情况是怎样的? 根据屏幕尺寸和分辨率,ios现在数起来有6个版本.一,3GS:二,4s为代表:三,iphone5:四,ipad2为代表:五,ipad4 ...
- iOS屏幕尺寸和分辨率
iOS平台家族成员主要包括iPhone.iPod Touch和iPad,但是各类设备的分辨率各不相同,目前存在的尺寸主要有: iOS设备的尺寸多种多样,此外,屏幕的分辨率也有多种,总结如下表所示: 其 ...
- js网页判断移动终端浏览器版本信息是安卓还是苹果ios,判断在微信浏览器跳转不同页面,生成二维码
一个二维码,扫描进入网页,自动识别下载苹果和安卓客户端,判断网页如下,(只有苹果的微信不能自动跳转)所以加个微信判断. <!DOCTYPE html> <html> <h ...
随机推荐
- SQL中存储过程和自定义函数的区别
存储过程: 存储过程可以使得对数据库的管理.以及显示关于数据库及其用户信息的工作容易得多.存储过程是 SQL 语句和可选控制流语句的预编译集合,以一个名称存储并作为一个单元处理.存储过程存储在 ...
- LA 4127 - The Sky is the Limit (离散化 扫描线 几何模板)
题目链接 非原创 原创地址:http://blog.csdn.net/jingqi814/article/details/26117241 题意:输入n座山的信息(山的横坐标,高度,山底宽度),计算他 ...
- poj 3790 Recursively Palindromic Partitions (递推)
题目 题意:求输入的数字的递归回文. 思路:答案等于这个数字一半之前的所有的 之和. #include <iostream> #include <cstdio> #includ ...
- LA 4728 (旋转卡壳) Squares
题意: 求平面上的最远点对距离的平方. 分析: 对于这个数据量枚举肯定是要超时的. 首先这两个点一定是在凸包上的,所以可以枚举凸包上的点,因为凸包上的点要比原来的点会少很多,可最坏情况下的时间复杂度也 ...
- 【C#学习笔记】打开新进程
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 【C#学习笔记】载入图片并居中
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- solr4.5配置中文分词器mmseg4j
solr4.x虽然提供了分词器,但不太适合对中文的分词,给大家推荐一个中文分词器mmseg4j mmseg4j的下载地址:https://code.google.com/p/mmseg4j/ 通过以下 ...
- Android学习笔记一
一.eclipse中的十大快捷键: 1. ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的 ...
- Tour
题意: 给n个点的坐标,求形成的最短的闭合回路. 分析: 经典问题,dp[i][j]表示有1-i点再由j回到1点的最短距离,i点有两种情况,在去的路径上 dp[i][j]=min(dp[i][j],d ...
- XCode修改工程名注意
以下文字转载过来,在使用的过程中遇到几个问题 1.需要在 Build phases 里面,检查下 Link Binary With Libraries 以及Compline Sources 2.Bul ...