首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIInterfaceOrientation问题

UIInterfaceOrientation问题
EN

Stack Overflow用户
提问于 2013-06-20 12:50:34
回答 1查看 71关注 0票数 1

我希望我的iPhone应用程序全局运行,就像只允许UIInterfaceOrientationPortrait一样。但同时,我希望它能够意识到物理方向,以便以特定的方式做出反应,仅在显示器的有限区域内。我怎么才能得到这个呢?

我使用UIViewController的self.interfaceOrientation iVar做了一些测试,但似乎不起作用,因为这个变量不会改变。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-20 13:04:18

首先,执行[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]。然后注册UIDeviceOrientationDidChangeNotification。收到通知后,请检查[UIDevice currentDevice].orientation以了解设备的物理方向。

您绝对应该阅读这些API的文档,因为其中包含一些重要的警告。

还要注意,设备方向是作为UIDeviceOrientation返回的,这与UIInterfaceOrientation不同。请记住UIInterfaceOrientation文档中的以下信息:

statusBarOrientation属性和setStatusBarOrientation:animated:方法中使用这些常量。请注意,UIDeviceOrientationLandscapeRight被分配给UIInterfaceOrientationLandscapeLeftUIDeviceOrientationLandscapeLeft被分配给UIInterfaceOrientationLandscapeRight;这样做的原因是旋转设备需要以相反的方向旋转内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17205495

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档