Aygıtın dikey veya yatay modda olup olmadığını bulmaya çalışıyorum. Cihaz yukarı bakmıyorsa kodum gayet iyi çalışıyor. Yüze dönükse (ve yönelim == 5), portre ve manzara arasında ayrım yapmaz. UIDeviceOrientation FaceUp ise, "yönlenme" yi yatay/dikey olarak belirlemek zaten var mı?UIDeviceOrientationFaceUp - portre ve manzara arasındaki farkı nasıl ayırt edersiniz?
Kodum: kendi beyanı
typedef enum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;
typedef enum {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
UIDeviceOrientation
gösterildiği gibi
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
NSLog(@"orientation: %d", interfaceOrientation);
if (interfaceOrientation == UIDeviceOrientationIsLandscape(interfaceOrientation)) {
NSLog(@"LANDSCAPE!!!");
}
if (interfaceOrientation == UIDeviceOrientationIsPortrait(interfaceOrientation)) {
NSLog(@"PORTRAIT!!!");
}