屏幕是横屏时,让页面也随着屏幕以横屏形式显示
2016-05-11 14:34
411 查看
用通知观察屏幕的情况
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(rotate)
name:UIDeviceOrientationDidChangeNotification
object:nil
];
-(void)rotate
{
UIDeviceOrientation orientation = [UIDevice
currentDevice].orientation;
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
if (interfaceOrientation ==
UIInterfaceOrientationPortrait ) {
//竖屏操作
}else
if(direction ==
UIInterfaceOrientationLandscapeRight)
{
//横屏操作
}
}
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(rotate)
name:UIDeviceOrientationDidChangeNotification
object:nil
];
-(void)rotate
{
UIDeviceOrientation orientation = [UIDevice
currentDevice].orientation;
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
if (interfaceOrientation ==
UIInterfaceOrientationPortrait ) {
//竖屏操作
}else
if(direction ==
UIInterfaceOrientationLandscapeRight)
{
//横屏操作
}
}
相关文章推荐
- 记录一个非常实用的gif制作工具licecap
- linux如何关闭防火墙
- JDK1.5,Switch中使用Enum
- 【Spring】Spring oxm 入门初尝试
- jquery的on()方法控制还未创建的节点
- WPF 中动态创建和删除控件
- 锐捷Linux客户端使用方法(基于ubuntu16.04)
- 【框架-MFC】MFC 显示和隐藏 星号密码 以及如何预防被查看
- leetcode_c++:4sum(016)
- 三十四 操作文件和目录
- CDN 和 DNS
- PHP获取网卡的MAC地址原码,支持WIN/LINUX系统
- android简单的AIDL使用示例
- iOS 自定义视频播放器
- PHP Date()函数详细参数
- unity 按下鼠标左键随机生成物体Instantiate
- ajax中post和get
- PL/SQL developer 导出CSV文件
- java 重定向和转发的区别
- uCrop源码思路分析--难点攻破