iPhone,iPad横屏竖屏的判断

    xiaoxiao2026-10-06  1

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

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

        

        if (interfaceOrientation==UIInterfaceOrientationPortrait) {

            

        }else if (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown){

            

        }else if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft){

            

        }else if (interfaceOrientation==UIInterfaceOrientationLandscapeRight){

            

        }

        

    }

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

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

            //横屏

        }else{

            

            //竖屏

        }

    转载请注明原文地址: https://ju.6miu.com/read-1312680.html
    最新回复(0)