启动时确定 iPad 方向

发布于 2024-12-21 00:05:52 字数 366 浏览 4 评论 0原文

为什么当我在 iPad 模拟器中使用 didLoad 或 willAppear 中的以下方法时,设备总是认为其处于横向模式,而实际上它处于纵向模式。

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];    
NSLog(@"orientation - %i", UIInterfaceOrientationIsPortrait(orientation));

这在 iPhone 模拟器中工作得很好,还有其他方法可以找出设备方向吗?

我尝试在 app.plist 中添加支持的方向,但模拟器仍然认为其处于横向模式?

干杯,

how come when i use the following method in didLoad or willAppear with the iPad simulator the device always thinks its in landscape mode when its clearly in portrait.

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];    
NSLog(@"orientation - %i", UIInterfaceOrientationIsPortrait(orientation));

this works fine in the iPhone simulator, is there another way to find out the devices orientation?

I have tried adding the supported orientations in the app.plist, but still the simulator thinks its in landscape mode?

Cheers,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴随着你 2024-12-28 00:05:52

UIDeviceOrientation 不是一回事作为 UIInterfaceOrientation

尝试使用类似 [[UIApplication sharedApplication] statusBarOrientation] 的内容。

UIDeviceOrientation is not the same thing as UIInterfaceOrientation.

Try something like [[UIApplication sharedApplication] statusBarOrientation] instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文