Xcode: Getting warning " implicit conversion from enumeration type UIDeviceOrientation"

Pełne Ostrzeżenie:

Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'
/ Align = "left" / ]}
[self orientationChanged:interfaceOrientation];

Oto metoda:

- (void)orientationChanged:(UIInterfaceOrientation)interfaceOrientation 
Nie rozumiem, skąd pochodzi to Ostrzeżenie.
Author: Vadim Kotov, 2011-08-10

1 answers

UIDeviceOrientation odnosi się do fizycznej orientacji urządzenia, podczas gdy UIInterfaceOrientation odnosi się do orientacji interfejsu użytkownika. Kiedy wywołujesz swoją metodę

[self orientationChanged:interfaceOrientation];

Najprawdopodobniej przekazujesz go UIDeviceOrientation, Kiedy powinieneś, zgodnie z metodą, używać UIInterfaceOrientation.

Aby nieco rozwinąć ten punkt, UIDeviceOrientation jest właściwością klasy UIDevice i są takie Możliwe wartości:

UIDeviceOrientationUnknown - nie można określić

UIDeviceOrientationPortrait - Przycisk Home down

UIDeviceOrientationPortraitUpsideDown - Przycisk Home skierowany do góry

UIDeviceOrientationLandscapeLeft - przycisk Home zwrócony w prawo

UIDeviceOrientationLandscapeRight - przycisk Home skierowany w lewo

UIDeviceOrientationFaceUp - urządzenie jest płaskie, z ekranem skierowanym do góry [22]}

UIDeviceOrientationFaceDown - urządzenie jest płaskie, z ekranem skierowanym w dół [22]}

Jeśli chodzi o UIInterfaceOrientation, jest to właściwość UIApplication i zawiera tylko 4 możliwości, które odpowiadają orientacji paska stanu:

UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,

UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,

UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft

Aby uzyskać UIDeviceOrientation, używasz

[[UIDevice currentDevice] orientation]

I aby uzyskać UIInterfaceOrientation, używasz

[[UIApplication sharedApplication] statusBarOrientation] 
 90
Author: PengOne,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-08-10 18:22:58