Orientation - 3
来源:互联网 发布:非线性最优化方法 编辑:程序博客网 时间:2024/06/05 16:47
下面用在旋转视图控制器的几个方法,非常好用,其实还有大量的其他判断方法,都不太靠谱
#import "OrientationViewController.h"@interface OrientationViewController ()@property (nonatomic, assign) BOOL shouldRotate;@end@implementation OrientationViewController- (void)viewDidLoad{ [super viewDidLoad]; /* iOS7 视图进入的时候判断方向 */ if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8) { switch ([UIDevice currentDevice].orientation) { case UIDeviceOrientationPortrait: { NSLog(@"Portrait !!!"); break; } case UIDeviceOrientationLandscapeLeft: case UIDeviceOrientationLandscapeRight: { NSLog(@"Landspace !!!"); break; } default: NSLog(@"Unkown !!!"); break; } }}- (void)configureNotificaiton{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];}- (void)statusBarOrientationChange:(NSNotification *)notification{ /* 配合这个方法,用在更新界面,控制先后 */}#pragma mark - UIViewController (UIViewControllerRotation).- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; }- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{ [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8) { switch ([UIDevice currentDevice].orientation) { case UIDeviceOrientationPortrait: { NSLog(@"Portrait !!!"); break; } case UIDeviceOrientationLandscapeLeft: case UIDeviceOrientationLandscapeRight: { NSLog(@"Landspace !!!"); break; } default: NSLog(@"Unkown !!!"); break; } } else { /* iOS8 以上的处理 */ }}#pragma mark - Orientation Handler.- (BOOL)shouldAutorotate{ if (self.shouldRotate) return YES; else return NO;}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ if (self.shouldRotate) return YES; else return NO;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations{ if (!self.shouldRotate) { return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; } return UIInterfaceOrientationMaskAll;}@end
0 0
- Orientation - 3
- orientation
- JPEG Orientation
- About Orientation
- camera orientation
- orientation|keyboardHidden
- Orientation - 1
- Orientation - 2
- android:orientation
- Interface Orientation
- Device orientation vs interface orientation
- 关于Wrong orientation? No orientation specified问题
- The principles of service-orientation part 3 of 6: Service abstraction and reuse [by Thomas Erl]
- Readings in Service Orientation
- Orientation Histogram code
- WebKit General Orientation
- Orientation Changed Notification
- About device orientation
- PAT 1014 福尔摩斯的约会
- Rails默认更新用户密码策略的修改
- linux之openssl简单介绍
- python 乱序数组,list等有序结构的方法
- SQL Server 基础(一)
- Orientation - 3
- android-对 ContentResolver 的学习
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- 网海茫茫,有你最暖
- 分享几个android软件的源码和网站
- Android 音乐播放器获取数据
- 收藏的一些网站
- 关于薪水保险金的那些事
- Android的五种数据储存