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

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

Orientation - 3

2019-11-09 15:40:12
字體:
來源:轉載
供稿:網友

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

#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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华容县| 郎溪县| 连城县| 连平县| 广河县| 进贤县| 顺昌县| 乐业县| 宣化县| 辽阳县| 杨浦区| 平果县| 兰州市| 柳林县| 井研县| 郸城县| 灵璧县| 彭山县| 祁门县| 府谷县| 渑池县| 昭通市| 普陀区| 界首市| 秭归县| 广东省| 昌宁县| 长沙市| 平和县| 确山县| 平顺县| 曲水县| 新竹市| 婺源县| 普宁市| 德令哈市| 黄冈市| 卓尼县| 台中市| 宣武区| 贡山|