Mic*_*ith 24 xcode objective-c uiinterfaceorientation
完全警告:
Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'
Run Code Online (Sandbox Code Playgroud)
让它上线:
[self orientationChanged:interfaceOrientation];
Run Code Online (Sandbox Code Playgroud)
这是方法:
- (void)orientationChanged:(UIInterfaceOrientation)interfaceOrientation
Run Code Online (Sandbox Code Playgroud)
我真的不明白这个警告来自哪里.
Pen*_*One 92
UIDeviceOrientation
"设备" UIInterfaceOrientation
是指设备的物理方向,而是指用户界面的方向.当你打电话给你的方法
[self orientationChanged:interfaceOrientation];
Run Code Online (Sandbox Code Playgroud)
UIDeviceOrientation
根据方法,你很可能会把它传递给你UIInterfaceOrientation
.
只是为了扩展这一点,UIDeviceOrientation
是UIDevice
类的属性,并且有以下可能的值:
UIDeviceOrientationUnknown
- 无法确定
UIDeviceOrientationPortrait
- 主页按钮朝下
UIDeviceOrientationPortraitUpsideDown
- 主页按钮朝上
UIDeviceOrientationLandscapeLeft
- 面向右侧的主页按钮
UIDeviceOrientationLandscapeRight
- 主页按钮朝左
UIDeviceOrientationFaceUp
- 设备扁平,屏幕朝上
UIDeviceOrientationFaceDown
- 设备平坦,屏幕朝下
至于UIInterfaceOrientation
,它是一个属性,UIApplication
只包含4种可能性,它们对应于状态栏的方向:
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
Run Code Online (Sandbox Code Playgroud)
要得到UIDeviceOrientation
,你使用
[[UIDevice currentDevice] orientation]
Run Code Online (Sandbox Code Playgroud)
并获得UIInterfaceOrientation
,你使用
[[UIApplication sharedApplication] statusBarOrientation]
Run Code Online (Sandbox Code Playgroud)