完整警告:
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
。为了进一步说明这一点,
UIDeviceOrientation
是UIDevice
类的属性,并且有以下可能的值:对于
UIInterfaceOrientation
,它是UIApplication
的属性,仅包含4种与状态栏方向相对应的可能性:UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
要获取UIDeviceOrientation
,您可以使用[[UIDevice currentDevice] orientation]
并获得UIInterfaceOrientation
,您可以使用[[UIApplication sharedApplication] statusBarOrientation]