我想知道设备是处于横屏还是竖屏模式。我的代码在设备没有朝上时很好用。但如果它朝上了(并且orientation == 5),它将无法区分横屏和竖屏。是否有办法在UIDeviceOrientation为FaceUp时确定“方向”(横屏/竖屏)呢?
我的代码:
我的代码:
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
NSLog(@"orientation: %d", interfaceOrientation);
if (interfaceOrientation == UIDeviceOrientationIsLandscape(interfaceOrientation)) {
NSLog(@"LANDSCAPE!!!");
}
if (interfaceOrientation == UIDeviceOrientationIsPortrait(interfaceOrientation)) {
NSLog(@"PORTRAIT!!!");
}