iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Xcode:获取警告“枚举类型的隐式转换UIDeviceOrientation”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

全面警告: Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation' 把它放在一起: [self orientationChanged:interfaceOrientation]; 这是方法: - (void)orien
全面警告:

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

把它放在一起:

[self orientationChanged:interfaceOrientation];

这是方法

- (void)orientationChanged:(UIInterfaceOrientation)interfaceOrientation

我不知道这个警告来自哪里,我不是世界上最好的Xcoder,但我可以通过这个数字来确定。

任何帮助将不胜感激。

解决方法

UIDeviceOrientation是指设备的物理方向,而UIInterfaceOrientation是指用户界面的方向。当你打电话给你的方法

[self orientationChanged:interfaceOrientation];

当您应该根据该方法使用UIInterfaceOrientation时,您最有可能传递一个UIDeviceOrientation。

只是为了扩展这一点,UIDeviceOrientation是UIDevice类的一个属性,并且有这些可能的值:

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

UIInterfaceOrientationPorTrait = UIDeviceOrientationPorTrait,UIInterfaceOrientationPorTraitUpsideDown = UIDeviceOrientationPorTraitUpsideDown,UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft

获取UIDeviceOrientation,请使用

[[UIDevice currentDevice] orientation]

获取UIInterfaceOrientation,您可以使用

[[UIApplication sharedApplication] statusBarOrientation]

大佬总结

以上是大佬教程为你收集整理的Xcode:获取警告“枚举类型的隐式转换UIDeviceOrientation”全部内容,希望文章能够帮你解决Xcode:获取警告“枚举类型的隐式转换UIDeviceOrientation”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。