Ответ 1
UIDeviceOrientation
относится к физической ориентации устройства, тогда как UIInterfaceOrientation
относится к ориентации пользовательского интерфейса. Когда вы вызываете свой метод
[self orientationChanged:interfaceOrientation];
вы, скорее всего, передаете его UIDeviceOrientation
, когда вам следует, согласно методу, использовать UIInterfaceOrientation
.
Просто чтобы развернуть эту точку немного, UIDeviceOrientation
является свойством класса UIDevice
, и есть следующие возможные значения:
UIDeviceOrientationUnknown
- Невозможно определить
UIDeviceOrientationPortrait
- Кнопка Home вниз вниз
UIDeviceOrientationPortraitUpsideDown
- кнопка "вверх" вверх
UIDeviceOrientationLandscapeLeft
- Кнопка "Главная", обращенная вправо
UIDeviceOrientationLandscapeRight
- Кнопка "Главная", обращенная влево
UIDeviceOrientationFaceUp
- Устройство плоское, экран вверх
UIDeviceOrientationFaceDown
- Устройство плоское, экран вниз вниз
Что касается UIInterfaceOrientation
, это свойство UIApplication
и содержит только 4 возможности, которые соответствуют ориентации строки состояния:
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
Чтобы получить UIDeviceOrientation
, вы используете
[[UIDevice currentDevice] orientation]
и чтобы получить UIInterfaceOrientation
, вы используете
[[UIApplication sharedApplication] statusBarOrientation]