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. 洛谷P1473 零的数列 Zero Sum

    P1473 零的数列 Zero Sum 134通过 170提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 路过的一定帮我看错了我死了- 题目描述 请考虑 ...

  2. Android添加权限大讲解

    对于新手来说,最烦恼的不是如何从网上下载到安卓项目,而是下载到的安卓项目不知道如何添加权限和要添加哪些权限. 现在就针对安卓的权限来讲解这些权限应该具体用在什么地方 首先在项目下找到 AndroidM ...

  3. ng-class ionic

    我发现 ng-class="{yourclass:true,outerclass:false}" 竟然不起作用...囧.... 幸好有Google  .... <p ng-c ...

  4. ERDAS 2013与ArcGIS10.1安装时的兼容性问题

    在Regedit中HKEY_LOCAL_MACHINE->SOFTWARE->FLEXlm License Manager下新建一个“ERDAS License Manager”,然后按照 ...

  5. 序列化和反序列化,异步调用web/wcf/函数

    //xml序列化 public static string Seria(DataSet ds) { XmlSerializer serializer = new XmlSerializer(typeo ...

  6. .net读取ini配置文件的操作

    #region 读取和写入ini文件的操作   string inipath = System.Windows.Forms.Application.StartupPath + @"\conf ...

  7. Windows phone 8 学习笔记(2) 数据文件操作(转)

    Windows phone 8 应用用于数据文件存储访问的位置仅仅限于安装文件夹.本地文件夹(独立存储空间).媒体库和SD卡四个地方.本节主要讲解它们的用法以及相关限制性.另外包括本地数据库的使用方式 ...

  8. Tomcat 7优化前及优化后的性能对比

    Tomcat 7在我们日常开发.测试.生产环境都会使用到,但对于大部分开发人员来说,对其性能还是没有多大了解.本文就对它做一次性能测试,对比优化前后的性能区别. 一.运行环境 CPU: Intel(R ...

  9. leetcode 26

    26. Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such th ...

  10. 下载uboot的调试版本到开发板的sdram中运行

    开发环境:开发板:FriendlyARM Tiny6410 主机:CentOS release 6.4 (Final) 开发板与主机通过串口线连接 调试用的uboot源码为开发板光盘提供的u-boot ...