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

最新文章

  1. 设计模式(八): 从“小弟”中来类比"外观模式"(Facade Pattern)
  2. Java实现购物车功能:方式一:存放在session中.方式二:存储在数据库中
  3. mvc 导入excel表格
  4. 调度系统任务创建---创建一个MultiJob的任务(四)
  5. 360浏览器下jquery.validate.unobtrusive的日期验证问题
  6. 刨根问底U3D---从Profile中窥探Unity的内存管理
  7. KM算法
  8. 怎么通过URL访问到服务器上的物理文件
  9. 8.PHP内核探索:再次探讨SAPI
  10. RAC和ASM环境下修改控制文件control file
  11. Android 文件的选择
  12. php获取数组长度的方法(有实例)
  13. PHP扩展开发(3)-config.m4
  14. 修复CefSharp浏览器组件中文输入Bug
  15. 64位windows8.1编译openjdk8
  16. poj 2411 Mondriaan's Dream dp
  17. mysql 优化方法
  18. ORA-00600[17059]错误
  19. JMeter 测试中,使用 JDBC 查询条件为中文时解决办法
  20. IIC时序和24C02读写字节时序

热门文章

  1. android 3D旋转效果实现
  2. JavaScript设计模式
  3. Hbase rest方式获取指定key范围内的值
  4. How to search compound files
  5. 凡聊过必留下痕迹-破解加密的WeChat数据库
  6. 图片无法显示,载入制定url失败
  7. HTML学习的开端
  8. eclipse 导入jar包
  9. 使用NPOI操纵Excle,并输入到客户端
  10. 关于ASP.net TextBox控件的失去焦点后触发其它事件