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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊通| 晋州市| 马关县| 阿拉善盟| 洛扎县| 威远县| 舟曲县| 屯昌县| 视频| 徐闻县| 周口市| 宝清县| 镇坪县| 沙田区| 呼伦贝尔市| 佛冈县| 思南县| 白河县| 盐津县| 哈密市| 古蔺县| 荥经县| 桐庐县| 林西县| 水城县| 阿鲁科尔沁旗| 长兴县| 若尔盖县| 海安县| 桑植县| 梁河县| 绩溪县| 三台县| 大新县| 松滋市| 和平县| 长春市| 酒泉市| 桂东县| 甘泉县| 广昌县|