在哪里可以获得特定于旋转的 appFrame?

发布于 2024-10-30 15:23:22 字数 200 浏览 3 评论 0原文

如何检索旋转特定的应用程序框架/屏幕边界?在 iPad 上,“applicationFrame”方法始终返回 768x1024,无论设备处于横向还是纵向模式。我正在寻找一种方法,如果设备处于横向,则返回 1024x768,如果处于纵向,则返回 768x1024。

我确信那里有类似的东西,但我就是找不到它。如果它真的不存在,如何使您的 iPad 应用程序横向和纵向兼容?

How can I retrieve a rotation specific applicationFrame/screen bounds? The "applicationFrame" method always returns 768x1024 on the iPad, no matter whether the device is in landscape or portrait mode. I am looking for a method that would return me 1024x768 if the device is in landscape and 768x1024 if its in portrait.

I am sure there is something like this out there but I just can't find it. In case it really doesn't exist, how do make your iPad apps landscape and portrait compatible?

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

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

发布评论

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

评论(2

绮筵 2024-11-06 15:23:22
[UIDevice currentDevice].orientation

将返回其中之一

typedef enum {
    UIDeviceOrientationUnknown,
    UIDeviceOrientationPortrait,
    UIDeviceOrientationPortraitUpsideDown,
    UIDeviceOrientationLandscapeLeft,
    UIDeviceOrientationLandscapeRight,
    UIDeviceOrientationFaceUp,
    UIDeviceOrientationFaceDown
} UIDeviceOrientation;

从那里,您可以推断出当前帧应该是什么。

[UIDevice currentDevice].orientation

Will return one of

typedef enum {
    UIDeviceOrientationUnknown,
    UIDeviceOrientationPortrait,
    UIDeviceOrientationPortraitUpsideDown,
    UIDeviceOrientationLandscapeLeft,
    UIDeviceOrientationLandscapeRight,
    UIDeviceOrientationFaceUp,
    UIDeviceOrientationFaceDown
} UIDeviceOrientation;

From there, you can deduce what the current frame should be.

挽容 2024-11-06 15:23:22

事实证明,applicationFrame 工作正常,但前提是自动旋转正确实现!在我的例子中,作为子视图添加到 UIWindow 的视图的控制器被过早释放,这似乎导致 applicationFrame 与自动旋转机制一起中断。我认为这是因为响应者链无法再正常运行,但我没有验证这一点。

Turns out applicationFrame works fine, but only if the autorotation is properly implemented! In my case the controller of the view that was added as subview to the UIWindow was released too early, which seems to cause applicationFrame to break along with the autorotation mechanism. I think this is because the responder chain can no longer function properly, yet I did not verify this.

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