判斷手機當前是橫屏仍是豎屏

1. ios

#define kScreen_Width [UIScreen mainScreen].bounds.size.widthide

橫屏和豎屏的時候,kScreen_Width的值是不同的.spa

2.利用系統自帶的方法,當屏幕發生轉動的時候會自動調用這個方法.在ios9的時候,這個方法不建議使用了.可是咱們如今最低適配ios8,因此仍是要用這個方法.3d

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {orm

    //    UIInterfaceOrientationUnknown            = UIDeviceOrientationUnknown,ios9

// home鍵在下邊it

    //    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,io

// home鍵在上邊ios8

    //    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,方法

// home鍵在左邊

    //    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,

// home鍵在右邊

    //    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft


}


判斷橫屏豎屏的時候,要注意應用都支持哪幾個方向.模擬器是不支持home鍵在上邊的時候的顯示的.

相關文章
相關標籤/搜索