LoginStateFail, }; 在定义选项的时候,若这些选项可以彼此组合,各个选项之间可以通过按“按位或操作符”来组合,那么枚举值中可定义为2的幂 typedef NS_ENUM(NSInteger, UIInterfaceOrientation UIInterfaceOrientationLandscapeLeft = 1 << 2, UIInterfaceOrientationLandscapeRight = 1 << 3, } - (UIInterfaceOrientation
UIInterfaceOrientation方向枚举: UIInterfaceOrientationPortrait //home健在下 UIInterfaceOrientationPortraitUpsideDown NSTimeInterval)duration { } //视图旋转动画前一半发生之前自动调用 -(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation fromInterfaceOrientation { } //视图旋转动画前一半发生之后自动调用 -(void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation 然后在这个类里面写上下面的代码,在使用的时候就用自定义的这个navCtr, 就是说需要在根视图里面控制 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0); ----
要翻转的时候,首先响应的方法: (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 紧接着 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:( 再来是 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration weakSelf = self; [UIView animateWithDuration:0.5 animations:^{ if (weakSelf.isFullScreenPlay) { //设置状态栏为竖屏 UIInterfaceOrientation keyWindow addSubview:weakSelf.playerView]; weakSelf.isFullScreenPlay = YES; //设置状态栏为横屏 UIInterfaceOrientation
UIInterfaceOrientation程序界面的当前旋转方向(可以设置),其源码的定义如下: // Note that UIInterfaceOrientationLandscapeLeft 而UIInterfaceOrientation和UIInterfaceOrientationMask的区别是什么呢? 其实观察源码,我们就会发现这是一种为了支持多种UIInterfaceOrientation而定义的类型。 //方法3 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0) __ 方法3作用是设置进入界面默认支持的方向,使用了返回值类型UIInterfaceOrientation,默认进入界面的方向是个确定的方向,所以使用UIInterfaceOrientation更适合。
UIDeviceOrientationFaceUp, // 屏幕朝上 UIDeviceOrientationFaceDown // 屏幕朝下 } UIInterfaceOrientation UIInterfaceOrientation,表示页面内容朝向,注意UIInterfaceOrientation和UIDeviceOrientation的关系,其中UIInterfaceOrientationLandscapeLeft 不用特别细究两者之间关系,我们只需要根据需要设置好UIInterfaceOrientation即可,通过 [UIApplication shareApplication] statusBarOrientation typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown self presentViewController:landVC animated:YES completion:nil]; } // LandscapeViewController内部代码 - (UIInterfaceOrientation
在iOS7及以前得到屏幕旋转方向的方法 /** // UIInterfaceOrientation ,屏幕方向 UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft */ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation duration { // 即将旋转执行动画 NSLog(@"%s", __func__); } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientation with the accelerometer; this is an overriden method.// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation
现在我们来看决定屏幕方向的几个函数: 在IOS6之前,我们只需通过一个函数 - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation supportedInterfaceOrientations and/or shouldAutorotate.. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation
pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation
UISplitViewController *) sender shouldHideViewController:(UIViewController *)master inOrientation:(UIInterfaceOrientation UISplitViewController *)sender shouldHideViewController:(UIViewController *)master inOrientation:(UIInterfaceOrientation
查阅了开发文档了解supportedInterfaceOrientations方法的使用,发现其返回值实际是UIInterfaceOrientationMask 类型,而项目中却返回了UIInterfaceOrientation 类型,二者虽然长得很相似,但用处完全不一样: UIInterfaceOrientationMask类型用来表示UIViewController能支持的方向 UIInterfaceOrientation类型用来表示
-(BOOL) shouldAutorotate{ return Yes; } -(NSUInteger) supportedInterfaceOrientations{ } -(UIInterfaceOrientation
UIDeviceOrientationFaceDown: return @"FaceDown"; } } NSString *MOInterfaceOrientationDescription(UIInterfaceOrientation
相关属性说明 Name Type Desc Default animateDuration Double 进入/退出 全屏时的旋转动画时间 0.25 enterFullScreenOrientation UIInterfaceOrientation
completion __attribute((objc_requires_super)); //设备旋转方向时调用的方法 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation NSTimeInterval)duration __attribute((objc_requires_super)); -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation
myWebView.scrollView.bounces = false; } override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation
StatusBar框将要变化时执行 10、- (void)application:(UIApplication*)application willChangeStatusBarOrientation: (UIInterfaceOrientation url 说明:当通过url执行 12、- (void)application:(UIApplication*)application didChangeStatusBarOrientation:(UIInterfaceOrientation
UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation
UIInterfaceOrientationMask)sd_supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation
navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController; (4)设置导航控制器的首选设备方向 - (UIInterfaceOrientation