警告:从枚举类型隐式转换UIInterfaceOrientation'不同的枚举类型“UIDeviceOrientation”?
在这一行中: [self deviceInterfaceOrientationChanged:interfaceOrientation];
我收到此警告,
Implicit conversion from enumeration type ' UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'?
您可以帮助我吗?谢谢你
这是代码:
-(void) receivedRotate: (NSNotification*) notification { NSLog(@"receivedRotate"); UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; if(interfaceOrientation != UIDeviceOrientationUnknown) { [self deviceInterfaceOrientationChanged:interfaceOrientation]; } else { NSLog(@"Unknown device orientation"); } }
In this line: [self deviceInterfaceOrientationChanged:interfaceOrientation];
I get this warning
Implicit conversion from enumeration type ' UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'?
Can u help me ?please. thank u
Here's the code:
-(void) receivedRotate: (NSNotification*) notification { NSLog(@"receivedRotate"); UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; if(interfaceOrientation != UIDeviceOrientationUnknown) { [self deviceInterfaceOrientationChanged:interfaceOrientation]; } else { NSLog(@"Unknown device orientation"); } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIDeviceOrientation 和 UIInterfaceOrientation 是不同的类型,第一个是设备方向,包括其他状态,例如面朝上或面朝下等,而第二个仅涵盖 2D 状态,例如纵向和横向。
不要从设备获取设备方向,而是从状态栏获取,如下所示:
此方法将返回 UIInterfaceOrientation 值,问题就会消失。
UIDeviceOrientation and UIInterfaceOrientation are different types, the first is the device orientation and includes other states like Face up or Face Down among others, while the second only covers 2D states, like Portrait and Landscape.
Don't get the device orientation from the device but from the status bar like this:
This method will return a UIInterfaceOrientation value and the problem will go away.