状态栏框架坚持纵向方向并遮挡 window.view

发布于 2024-12-12 06:21:04 字数 637 浏览 0 评论 0原文

我正在开发一个应该支持所有方向的 iPad 应用程序。我没有使用笔尖。我有一个 UIWindow,它布局了四个视图:

其中两个占据整个宽度,但高度不多。
另外两个占据了大部分高度,并且共享相同的 origin.x。它们不重叠。

我将一个视图指定为主窗口的子视图,并将其余视图指定为 window.view。

问题:旋转后,无论方向如何,状态栏的框架都会粘在其原始位置(纵向顶部)。不过,状态栏确实会旋转。

我确实注意到 red-glasses内容丰富的文章。但是,这似乎并不是完全相同的问题。这是不同的,因为红眼镜方法通过将主视图设置为窗口的子视图来设法覆盖状态栏条。我已经采取了这种方法,但问题仍然存在。

我尝试在 willRotateToInterfaceOrientation:: 中重新构建和重新设置 window.view 框架 运气不佳。我已经验证新的框架/中心是我所期望的。看起来好像后台正在进行一些重构。

我不知道此时该怎么想...... 我希望有人能够对这个主题有所启发。

I'm working on a iPad application that should support all orientations. I am not using nibs. I have a UIWindow that lays out four views:

Two of which take up full width, but not much height.
The other two take up the bulk of the height, and share the same origin.x. They do not overlap.

I designate one view as the main window's subview, and subview the rest to window.view.

The issue: after rotation, it appears as thought the status bar's frame sticks to its original position (top of portrait orientation) regardless of orientation. Although, the status bar does rotate.

I did note red-glasses informative article. But, this doesn't appear quite the same problem. This is different in the sense that red-glasses approach managed to cover the status bar strip by setting the main view as the window's subview. I have taken this approach, but the issue persists.

I've tried reframing and recentering the window.view frame in willRotateToInterfaceOrientation::
with little luck. I have verified that the new frames/centers are what I would expect. It appears as though there is some reframing going on in the background.

I'm not sure what to think at this point...
I'm hoping that someone can shed some light on this subject.

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

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

发布评论

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

评论(1

鱼窥荷 2024-12-19 06:21:04

最后!我的观点一致。
原来问题出在 didFinishLaunchingWithOptions:

问题是我通过 initWithFrame:[[UIScreen mainScreen] applicationFrame]; 初始化我的 UIWindow

当我使用 init 进行初始化时,视图按预期定位。仅当我将重构代码留在 willRotateToInterfaceOrientation: 中时(如上所述),它才有效。

在 willRotateToInterfaceOrientation: 中,我计算并为每个视图设置正确的帧,然后使用 UIView animateWithDuration::::: 将转换集成到旋转动画中,

我将倒数第二个选择器参数中的新帧设置为 animateWithDuration。

希望这对某人有帮助...

Finally! I got the views aligning coherently.
Turns out the problem was in didFinishLaunchingWithOptions:

The problem was I was initializing my UIWindow via initWithFrame:[[UIScreen mainScreen] applicationFrame];

When I initialized using init instead the views were positioned as expected. It only works when I leave the reframing code in willRotateToInterfaceOrientation: (as noted above).

In willRotateToInterfaceOrientation:, I calculated and set the correct frame for each view, then integrated the transformation into the rotation animation using UIView animateWithDuration:::::

I set the new frames in the second to last selector argument to animateWithDuration.

Hope this helps someone...

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