ios 屏幕旋转监测
2017-01-05 14:28
423 查看
最近做一个视频播放的页面,要有全屏播放的功能,所以需要检测屏幕的旋转的方向
代码如下
方法一
先添加通知
通知调用方法
方法二
也可以用下面的方法
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait) {
NSLog(@"UIInterfaceOrientationPortrait");
}else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"UIInterfaceOrientationPortraitUpsideDown");
}else if (orientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"UIInterfaceOrientationLandscapeLeft");
}else if (orientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"UIInterfaceOrientationLandscapeRight");
}else {
NSLog(@"UIInterfaceOrientationUnknown");
}
}
代码如下
方法一
先添加通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(change:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
通知调用方法
- (void)change:(NSNotification *)noti { UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait) { NSLog(@"UIInterfaceOrientationPortrait"); }else if (orientation == UIInterfaceOrientationPortraitUpsideDown) { NSLog(@"UIInterfaceOrientationPortraitUpsideDown"); }else if (orientation == UIInterfaceOrientationLandscapeLeft) { NSLog(@"UIInterfaceOrientationLandscapeLeft"); }else if (orientation == UIInterfaceOrientationLandscapeRight){ NSLog(@"UIInterfaceOrientationLandscapeRight"); }else { NSLog(@"UIInterfaceOrientationUnknown"); } }
方法二
也可以用下面的方法
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait) {
NSLog(@"UIInterfaceOrientationPortrait");
}else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"UIInterfaceOrientationPortraitUpsideDown");
}else if (orientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"UIInterfaceOrientationLandscapeLeft");
}else if (orientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"UIInterfaceOrientationLandscapeRight");
}else {
NSLog(@"UIInterfaceOrientationUnknown");
}
}
相关文章推荐
- iOS屏幕旋转的监测
- iOS强制旋转屏幕
- ios旋转屏幕总结 详细教程
- iOS 5.1实现旋转屏幕
- ios6.0之后单个屏幕旋转,不用根视图以及Application windows are expected to have a root view controller at the end of
- ios 6.0 屏幕旋转问题
- ios开发之 屏幕旋转
- 关于IOS屏幕的旋转问题
- iOS 5.1及6.0 屏幕旋转的兼容问题
- ios 6 的变化 与 旋转屏幕控制
- iOS 6.0屏幕旋转的问题
- ios 旋转屏幕横竖屏总结
- ios-旋转屏幕 通用方法
- IOS成长之路-关于iOS6.0 屏幕旋转的问题
- ios 6 与 ios5 的屏幕旋转
- IOS设备屏幕旋转相关技术收集
- IOS 设备屏幕旋转相关收集
- 关于iOS6.0 屏幕旋转的问题
- IOS:屏幕旋转学习笔记
- iOS学习笔记(3)— 屏幕旋转