完整警告:

Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'

上线:
[self orientationChanged:interfaceOrientation];

这是方法:
- (void)orientationChanged:(UIInterfaceOrientation)interfaceOrientation

我真的不明白这个警告是从哪里来的。

最佳答案

UIDeviceOrientation是指设备的物理方向,而UIInterfaceOrientation是指用户界面的方向。当您调用方法时

[self orientationChanged:interfaceOrientation];
根据该方法,您最有可能在应使用UIDeviceOrientation的情况下将其传递给UIInterfaceOrientation
为了进一步说明这一点,UIDeviceOrientationUIDevice类的属性,并且有以下可能的值:

对于UIInterfaceOrientation,它是UIApplication的属性,仅包含4种与状态栏方向相对应的可能性:
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,

UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,

UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
要获取UIDeviceOrientation,您可以使用
[[UIDevice currentDevice] orientation]
并获得UIInterfaceOrientation,您可以使用
[[UIApplication sharedApplication] statusBarOrientation]

10-08 11:39