1. let orientation: UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation
  2. println("Currently landscape: " + ((orientation == UIInterfaceOrientation.LandscapeLeft||orientation == UIInterfaceOrientation.LandscapeRight) ?"YES":"NO"))
  3. println("UIScreen.mainScreen().bounds: \(UIScreen.mainScreen().bounds)")
  4. println("UIScreen.mainScreen().applicationFrame: \(UIScreen.mainScreen().applicationFrame)")
   let orientation: UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation
println("Currently landscape: " + ((orientation == UIInterfaceOrientation.LandscapeLeft||orientation == UIInterfaceOrientation.LandscapeRight) ?"YES":"NO"))
println("UIScreen.mainScreen().bounds: \(UIScreen.mainScreen().bounds)")
println("UIScreen.mainScreen().applicationFrame: \(UIScreen.mainScreen().applicationFrame)")

在ios7中输出:

Currently landscape: NO

UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)

UIScreen.mainScreen().applicationFrame: (0.0,20.0,320.0,548.0)

Currently landscape: YES

UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)

UIScreen.mainScreen().applicationFrame: (20.0,0.0,300.0,568.0)

在ios8中输出:

Currently landscape: NO

UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)

UIScreen.mainScreen().applicationFrame: (0.0,20.0,320.0,548.0)

Currently landscape: YES

UIScreen.mainScreen().bounds: (0.0,0.0,568.0,320.0)

UIScreen.mainScreen().applicationFrame: (0.0,0.0,568.0,320.0)

结论:

1、在ios7中UIScreen.mainScreen().bounds是固定不变的值,在ios8中他的值是随横竖屏改变的!

为了在ios8中得到原来的效果可以:

  1. + (CGSize)screenSize {
  2. CGSize screenSize = [UIScreen mainScreen].bounds.size;
  3. return CGSizeMake(MIN(screenSize.width, screenSize.height), MAX(screenSize.width, screenSize.height));
  4. }
+ (CGSize)screenSize {
CGSize screenSize = [UIScreen mainScreen].bounds.size;
return CGSizeMake(MIN(screenSize.width, screenSize.height), MAX(screenSize.width, screenSize.height));
}

2、

在ios8中增加了2个属性:

nativeBounds :  屏幕像素,不随横竖平改变的!

nativeScale   :1(non retina)/2(retina)/3(retina hd)

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/nativeBounds

ios8输出:

Currently landscape: YES

UIScreen.mainScreen().bounds: (0.0,0.0,568.0,320.0)

UIScreen.mainScreen().applicationFrame: (0.0,20.0,568.0,300.0)

UIScreen.mainScreen().nativeBounds: (0.0,0.0,640.0,1136.0)

UIScreen.mainScreen().nativeScale: 2.0

Currently landscape: NO

UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)

UIScreen.mainScreen().applicationFrame: (0.0,20.0,320.0,548.0)

UIScreen.mainScreen().nativeBounds: (0.0,0.0,640.0,1136.0)

UIScreen.mainScreen().nativeScale: 2.0

3、从UIScreen.mainScreen().applicationFrame输出值看出,ios8默认横屏statusbar是隐藏掉了。你可以根据plist中

View controller-based status bar appearance的值的不同来用

  1. UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)

  1. override func prefersStatusBarHidden() -> Bool {
  2. return false
  3. }
  override func prefersStatusBarHidden() -> Bool {
return false }

显示横屏statusbar

ios8中的UIScreen的更多相关文章

  1. iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)

    最近在写一个LBS的项目的时候,因为考虑到适配iOS8,就将项目迁移到Xcode6.0.1上,出现了不能正常获取定位服务权限的问题. self.manger = [[CLLocationManager ...

  2. iOS8中使用CoreLocation定位[转]

    本文转自:http://blog.devzeng.com/blog/ios8-corelocation-framework.html iOS8以前使用CoreLocation定位 1.首先定义一个全局 ...

  3. iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口

    1.IOS8中使用UIAlertController创建警告窗口 #pragma mark - 只能在IOS8中使用的,警告窗口- (void)showOkayCancelAlert{    NSSt ...

  4. iOS8中添加的extensions总结(一)——今日扩展

    通知栏中的今日扩展 分享扩展 Action扩展 图片编辑扩展 文件管理扩展 第三方键盘扩展 注:此教程来源于http://www.raywenderlich.com的<iOS8 by Tutor ...

  5. ios8中百度推送接收不到

    ios8中百度推送接收类型会有所改变: //消息推送注冊 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { ...

  6. 初探 iOS8 中的 Size Class

    初探 iOS8 中的 Size Class 分类: Ios2014-09-16 13:11 4323人阅读 评论(1) 收藏 举报   目录(?)[+]   初探 iOS8 中的 Size Class ...

  7. iOS8中的动态文本

    原文链接 : Swift Programming 101: Mastering Dynamic Type in iOS 8 原文作者 : Kevin McNeish Apple声称鼓励第三方App能够 ...

  8. iOS8中 UITableView section 分区头部视图不显示

    最近自己使用了UITableView写了一个通讯录,但是在编写过程还算顺利,但是后来测试的时候,发现在iOS8中TableView的分区头不能正常显示,使用 - (NSString *)tableVi ...

  9. iOS8中 UILocalNotification 和 UIRemoteNotification 使用注意

    先说一个关于UILocalNotification的知识点,容易被忘记: Each app on a device is limited to 64 scheduled local notificat ...

随机推荐

  1. c++11 中的 move 与 forward

    [update: 关于左值右值的另一点总结,请参看这篇] 一. move 关于 lvaue 和 rvalue,在 c++11 以前存在一个有趣的现象:T&  指向 lvalue (左传引用), ...

  2. StackExchange.Redis使用和封装小试

    StackExchange.Redis使用和封装小试 https://git.oschina.net/Ultralisk/ThorActor/blob/ThorActor/DBUtility/Redi ...

  3. CSS 居中效果完整指南

    本文翻译自:<Centering in CSS: A Complete Guide> 使用 CSS 实现效果困难吗?显然不是.实际上有许多方法可以实现居中效果,但在具体情况中,我们往往无法 ...

  4. 设计模式-原型模式(Prototype)

    场景分析: 前面我们提到,交易对象Trade,还有继承他的债券交易BondTrade.期货交易FutureTrade. 现在有一个需求,需要提供方法将交易拆分成多笔小交易. 代码如下(如果没有clon ...

  5. 将ubuntu12.04中,gcc4.6/g++4.6版本降低到gcc4.4/g++4.4.

    降低Ubuntu中gcc和g++的版本 ubuntu 12.04 中带的gcc/g++都是4.6,将其降到4.4. 操作步骤如下: 一.降低gcc版本 1. $sudo apt-get install ...

  6. CentOS学习笔记--SCSI 设备热插拔

    CentOS学习笔记--SCSI 设备热插拔 处于运行中的服务器,因业务要求也许不允许重启机器,而新添加的SCSI设备(主要是硬盘)如何实现热插拔呢? 首先需要查看一下设备: #cat /proc/s ...

  7. mvc路由设置参数配置类似于url重写

    1.新建的mvc项目中Global.asax 2.在另外一个控制器中的视图中 3. 4.

  8. js各种宽高(1)

    在javascript中操作dom节点让其运动的时候,常常会涉及到各种宽高以及位置坐标等概念,如果不能很好地理解这些属性所代表的意义,就不能理解js的运动原理,同时,由于这些属性概念较多,加上浏览器之 ...

  9. php中empty(), is_null(), isset()函数区别

    empty(), is_null(), isset()真值表(区别) 我们先来看看这3个函数的功能描述 www.111cn.net isset 判断变量是否已存在,如果变量存在则返回 TRUE,否则返 ...

  10. WIN7 X64 解决无法安装IE11,以及无法点击微软升级包MSU的问题

    一般在官方下载的文件是MSU格式的后缀文件,这个文件属于系统升级包补丁:下载完毕之后直接点击安装会报错,错误提示如下:安装程序遇到错误:0x80070422 无法启动服务,原因可能是已被禁用或与其相关 ...