ios8中的UIScreen
- 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)")
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中得到原来的效果可以:
- + (CGSize)screenSize {
- CGSize screenSize = [UIScreen mainScreen].bounds.size;
- return CGSizeMake(MIN(screenSize.width, screenSize.height), MAX(screenSize.width, screenSize.height));
- }
+ (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)
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的值的不同来用
- UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
或
- override func prefersStatusBarHidden() -> Bool {
- return false
- }
override func prefersStatusBarHidden() -> Bool {
return false
}
显示横屏statusbar
ios8中的UIScreen的更多相关文章
- iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)
最近在写一个LBS的项目的时候,因为考虑到适配iOS8,就将项目迁移到Xcode6.0.1上,出现了不能正常获取定位服务权限的问题. self.manger = [[CLLocationManager ...
- iOS8中使用CoreLocation定位[转]
本文转自:http://blog.devzeng.com/blog/ios8-corelocation-framework.html iOS8以前使用CoreLocation定位 1.首先定义一个全局 ...
- iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口
1.IOS8中使用UIAlertController创建警告窗口 #pragma mark - 只能在IOS8中使用的,警告窗口- (void)showOkayCancelAlert{ NSSt ...
- iOS8中添加的extensions总结(一)——今日扩展
通知栏中的今日扩展 分享扩展 Action扩展 图片编辑扩展 文件管理扩展 第三方键盘扩展 注:此教程来源于http://www.raywenderlich.com的<iOS8 by Tutor ...
- ios8中百度推送接收不到
ios8中百度推送接收类型会有所改变: //消息推送注冊 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { ...
- 初探 iOS8 中的 Size Class
初探 iOS8 中的 Size Class 分类: Ios2014-09-16 13:11 4323人阅读 评论(1) 收藏 举报 目录(?)[+] 初探 iOS8 中的 Size Class ...
- iOS8中的动态文本
原文链接 : Swift Programming 101: Mastering Dynamic Type in iOS 8 原文作者 : Kevin McNeish Apple声称鼓励第三方App能够 ...
- iOS8中 UITableView section 分区头部视图不显示
最近自己使用了UITableView写了一个通讯录,但是在编写过程还算顺利,但是后来测试的时候,发现在iOS8中TableView的分区头不能正常显示,使用 - (NSString *)tableVi ...
- iOS8中 UILocalNotification 和 UIRemoteNotification 使用注意
先说一个关于UILocalNotification的知识点,容易被忘记: Each app on a device is limited to 64 scheduled local notificat ...
随机推荐
- 学习练习 java 实例属性 静态属性
package com.hanqi; public class Test11Car11 { //静态 //实例属性 private int m = 0; //静态属性 //所有实例共有的,在内存里只有 ...
- 【MySQL】MySQL无基础学习和入门之二:MySQL的安装
安装MySQL安装一般分为源码包编译安装.分发包.rpm包安装和yum安装,四种安装方式有一些区别,对应的适用场景也不一样. 源码包:源码包就是程序源代码包,其中包含程序代码文件,这些代码文件是文本型 ...
- Android 6 Marshmallow USB调试授权
Google在Android在5.1版之后进行了重大变革,推出了Android 6 Marshmallow,我们先看看当它接上工作站时,有什么样的状况出现. 如图1所示,会弹出一个窗口,[是否允许此计 ...
- Linux下查看文件属性
1.ls ls -a 查看所有文件,就是包含隐藏文件 ls -l 查看详细的属性,包括文件类型(d表示目录,-表示普通文件,l表示链接文件),文件的权限(所有者权限,所属组权限,其他人权限),所有者, ...
- pect-shell中的自动交互
这是我在ST写的自动登陆ssh的脚本, 分两个文件 文件1: sssh #!/bin/bash #xql 2011/01/4#auto ssh 138.198.230.170 case $1 in & ...
- Android异常一、异步任务导致的窗口句柄泄漏问题(转)
05-05 10:36:41.009: E/WindowManager(4243): Activity com.tao.MyActivity has leaked window com.android ...
- MyEclipse各种操作
MyEclipse console没有显示的解决方法 1.进window菜单 ->show view->console 2.还是window菜单->preferences-& ...
- 利用脚本设置本机IP地址
各位同学,在日常工作中.常出现需要指定IP的地址的清况.为了解决这一个问题,我特意为自己编写了一段脚本.方便设定自己笔记本的IP地址.供大家参考. 其中包括无线wifi和有线网络设定两个IP的操作. ...
- php final static const成员属性用法
http://www.111cn.net/phper/php/38976.htm 首先来说说final 1.final不能用来修饰成员属性 2.final只能修饰类和方法 作用:被修饰的类不能被子类所 ...
- Thinkphp 下面执行crond
thinkphp开启cli支持 1.tp正好支持cli命令模式,手册的路径为13.7.4 如果是用的其他框架不支持cli,那么只能直接写程序了,其实就是写面向过程的最基础的php代码. 2.在入口文 ...