iOS开发——检测屏幕旋转
步骤一、注册通知
1: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
步骤二、判断方向
1: - (void)statusBarOrientationChange:(NSNotification *)notification
2:
3: {
4:
5: UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
6:
7: if (orientation == UIInterfaceOrientationLandscapeRight) // home键靠右
8:
9: {
10:
11: //
12:
13: }
14:
15: if (
16:
17: orientation ==UIInterfaceOrientationLandscapeLeft) // home键靠左
18:
19: {
20:
21: //
22:
23: }
24:
25: if (orientation == UIInterfaceOrientationPortrait)
26:
27: {
28:
29: //
30:
31: }
32:
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
参考来源:http://www.2cto.com/kf/201410/345818.html
最新文章
- GPS部标监控平台的功能设计(一)-功能列表
- 处理session跨域几种的方案
- 总结之H3C汇聚层交换机认证在线人数展示系统
- 习课的redis配置记录
- JVM byte code
- 【原】MyEclipse8.5集成Tomcat7时启动错误:Exception in thread “main” java.lang.NoClassDefFoundError
- c#多线程生产者消费者(手稿)
- Linux 系统常用命令汇总(二) vi 文本编辑
- Tombstone crash
- jquery基础教程读书总结
- Sqlserver 关于游标
- Python 基础篇:字符编码、函数
- html一些东东
- printf交替使用
- windows service and process 的关系
- PAT1048. Find Coins(01背包问题动态规划解法)
- android stuido 的几个点
- 50 years, 50 colors HDU
- ECMAScript5之Object学习笔记(一)
- ssh 配置文件讲解大全 ssh调试模式 sftp scp strace进行调试 特权分离
热门文章
- java.sql.Date和java.util.Date的不同和相互转换方式
- linux内核同步之每CPU变量、原子操作、内存屏障、自旋锁【转】
- nginx1.11.9 apt即源码编译各平台测试
- 关于一些Java基础数据类型的常用方法的应用场景的小思考
- 肢解 HTTP 服务器构建
- jquery 的combobox 处理级联
- delphi dispose释放内存的方法 New 和 GetMem 的区别
- 《Java编程思想》笔记 第五章 初始化与清理
- hdu 5179(数位DP||打表)
- 网络大数据分析 -- 使用 ElasticSearch + LogStash + Kibana 来可视化网络流量