iOS判断App版本号/iOS系统版本号/4gWiFi环境/当前设备类型/横竖屏

判断App版本号/iOS系统版本号/4gWiFi环境





判断当前设备类型:

    //判断当前设备的类型改变左右两边约束的距离

    if([UIDevice currentDevice].userInterfaceIdiom ==UIUserInterfaceIdiomPhone){

        self.leftConstraint.constant =10;

        self.rightConstraint.constant =10;

    }


判断是否是横屏:

1.if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){}

2.//将要旋转到某个方向的时候调用此方法(iOS8之前)

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{

    //Landscape : 横屏  Portrait: 竖屏

    

    // 传入一个方向值,如果是横屏,则返回YES

    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {

        NSLog(@"横屏");

    }

    

    // 传入一个方向值,如果是竖屏,则返回YES

    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {

        NSLog(@"竖屏");

    }

}


3.#pragma mark iOS8以后的方法

// 如果实现了iOS8以后的方法,则旧版方法会覆盖


//视图发生了大小改变的时候会调用此方法  大小改变 ==横竖切换

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

{

    NSLog(@"size; %@",NSStringFromCGSize(size));

    

    // 建议如果背景色不一致的情况下,做动画同步的处理,否则视觉上很不舒服

    

    //动画同步 -->系统默认0.25而选择是0.4

    [UIViewanimateWithDuration:[coordinatortransitionDuration]animations:^{

        //方法一:

        if (size.width ==HMScreenMaxWidth1024) {

            NSLog(@"横屏");

            self.dockView.width =HMDockMaxWidth;

            self.dockView.height =HMScreenMinWidth768;

        } else {

            NSLog(@"竖屏");

            self.dockView.width =HMDockMinWidth;

            self.dockView.height =HMScreenMaxWidth1024;

        }


    }];

    

    

    

    //方法二

//    if (size.width > size.height) {

//        NSLog(@"横屏");

//    }

    

    //方法三 orientation:方向

//    if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft || [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {

//        NSLog(@"横屏");

//    }

}


==============

#pragma mark 设置屏幕支持的方向 

//iOS9 返回值发生了改变这里必须要找带Mask的值

- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    returnUIInterfaceOrientationMaskLandscape;

}






  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值