码迷,mamicode.com
首页 > 移动开发 > 详细

iOS获取当前设备方向

时间:2015-02-15 19:16:32      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

三种方式:

  • 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

iOS获取当前设备方向

标签:

原文地址:http://www.cnblogs.com/xuejinhui/p/4293319.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!