关于iPhone的方向 [英] About the orientation of iPhone

查看:75
本文介绍了关于iPhone的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得iPhone的当前方向?
我冲浪过这个网站,发现了两种方法如下。

How to get the current orientation of iPhone? I surfed this site, and found two methods as followings.


  • [UIApplication sharedApplication] .statusBarOrientation;

  • [[UIDevice currentDevice] orientation];

哪一种是获得当前方向的正确方法?
我在模拟器4.1下尝试了两个方法,但这两种方法都有一些问题。

Which one is the right way to get the current orientation ? I tried two methods under simulator 4.1, but there are some problems for both methods.

推荐答案

[[UIDevice currentDevice] orientation] 获取设备的当前物理方向。 [UIApplication sharedApplication] .statusBarOrientation 获取UI的方向。如果应用程序返回NO到 shouldAutorotateToInterfaceOrientation:方法,这两个值将不相同。

[[UIDevice currentDevice] orientation] gets the current physical orientation of the device. [UIApplication sharedApplication].statusBarOrientation gets the orientation of the UI. If the app ever returns NO to the shouldAutorotateToInterfaceOrientation: method, the two values will not be the same.

这篇关于关于iPhone的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆