国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临武县| 丹寨县| 无极县| 安阳县| 阜阳市| 大庆市| 寿光市| 安吉县| 五原县| 汝南县| 攀枝花市| 甘泉县| 富顺县| 都兰县| 红河县| 山东| 阜城县| 巫山县| 班玛县| 昆山市| 密山市| 桃江县| 会理县| 莒南县| 朝阳市| 湖口县| 新干县| 琼海市| 玛沁县| 新巴尔虎右旗| 绥化市| 独山县| 河源市| 曲麻莱县| 绍兴县| 定南县| 莱芜市| 太仆寺旗| 锡林郭勒盟| 丹巴县| 绵阳市|