iPhone,iPad横屏竖屏的判断

来源:互联网 发布:ar2048n 网络打印设置 编辑:程序博客网 时间:2024/05/20 16:00

1.方法一:当屏幕变化时会自动调用此方法

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {

    

   if (interfaceOrientation==UIInterfaceOrientationPortrait) {

        

    }elseif (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown){

        

    }elseif (interfaceOrientation==UIInterfaceOrientationLandscapeLeft){

        

    }elseif (interfaceOrientation==UIInterfaceOrientationLandscapeRight){

        

    }

    

}


2.方法二:通过比较宽高判断

if ([UIScreenmainScreen].bounds.size.width>[UIScreen mainScreen].bounds.size.height) {

       //横屏

    }else{

        

        //竖屏

    }




0 0
原创粉丝点击