iOS获取当前设备方向
发布日期:2021-08-17 08:27:55 浏览次数:9 分类:技术文章

本文共 1146 字,大约阅读时间需要 3 分钟。

http://www.cnblogs.com/Yukang1989/p/3160980.html

 

 

三种方式:

  • self.interfaceOrientation
  • [[UIApplication sharedApplication] statusBarOrientation]
  • [[UIDevice currentDevice] orientation]

但是实际使用时有区别的:

self.interfaceOrientation returns UIInterfaceOrientation, current orientation of the interface. It is a property in UIViewController, you can access to this one only in UIViewController classes.

[[UIApplication sharedApplication] statusBarOrientation] returns UIInterfaceOrientation, current orientation of the application's status bar. You can access to that property in any point of your application. My experience shows that it's more effective way to retrieve real interface orientation.

[[UIDevice currentDevice] orientation] returns UIDeviceOrientation, device orientation. You can access to that property in any point of your application. But note that UIDeviceOrientation is not always UIInterfaceOrientation. For example, when your device is on a plain table you can receive unexpected value.

 

原文:http://stackoverflow.com/questions/7968451/different-ways-of-getting-current-interface-orientation

转载于:https://www.cnblogs.com/xuejinhui/p/4293319.html

转载地址:https://blog.csdn.net/weixin_30843605/article/details/95273140 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:What does this bit-manipulating function do?
下一篇:C++ string中的几个小陷阱,你掉进过吗?

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月10日 21时42分13秒