国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Orientation - 3

2019-11-09 14:31:44
字體:
來源:轉載
供稿:網友

下面用在旋轉視圖控制器的幾個方法,非常好用,其實還有大量的其他判斷方法,都不太靠譜

#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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 六盘水市| 张家口市| 郓城县| 泰州市| 咸宁市| 泽库县| 从化市| 磴口县| 邵阳县| 昆明市| 修武县| 同仁县| 崇义县| 冀州市| 吉林省| 侯马市| 化隆| 江津市| 翁牛特旗| 保定市| 民勤县| 池州市| 延安市| 鄂尔多斯市| 赤壁市| 新宁县| 广丰县| 广东省| 牡丹江市| 义乌市| 筠连县| 册亨县| 惠安县| 乌兰察布市| 阿尔山市| 德州市| 富宁县| 外汇| 穆棱市| 清流县| 三门县|