ios螢幕方向判斷,Home鍵向左向右判斷
阿新 • • 發佈:2019-01-22
判斷ios螢幕方向放置狀態。
- (void)Orientations
{
//宣告一個UIDevice指標,並取得目前Device的狀況
UIDevice *device = [UIDevicecurrentDevice] ;
//取得當前Device的方向,來當做判斷。(Device的方向型為Integer)
switch (device.orientation) {
caseUIDeviceOrientationFaceUp:
NSLog(@"螢幕朝上平躺");
break;
caseUIDeviceOrientationFaceDown:
NSLog(@"螢幕朝下平躺");
break;
//
caseUIDeviceOrientationUnknown:
NSLog(@"未知方向");
break;
caseUIDeviceOrientationLandscapeLeft:
NSLog(@"螢幕向左橫置");
break;
caseUIDeviceOrientationLandscapeRight:
NSLog(@"螢幕向右橫置");
break;
caseUIDeviceOrientationPortrait:
NSLog(@"螢幕直立");
break;
caseUIDeviceOrientationPortraitUpsideDown
NSLog(@"螢幕直立,上下顛倒");
break;
default:
NSLog(@"無法辨認");
break;
}
}