状态栏框架保持纵向,并遮住window.view [英] statusbar frame sticks to portrait orientation and occludes window.view

查看:84
本文介绍了状态栏框架保持纵向,并遮住window.view的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应该支持所有方向的iPad应用程序.我没有用笔尖.我有一个UIWindow列出了四个视图:

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:

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

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.

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

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.

我已尝试将willRotateToInterfaceOrientation中的window.view框架重新框架化和重新定位:: 运气不好.我已验证新框架/中心是否符合我的期望.似乎在后台进行了一些重新构图.

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.

推荐答案

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

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

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

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

当我使用init初始化时,视图按预期位置放置.仅当我将重排代码保留在willRotateToInterfaceOrientation:中时,它才起作用(如上所述).

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).

在willRotateToInterfaceOrientation:中,我计算并设置了每个视图的正确帧,然后使用UIView animateWithDuration :::::

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

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

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

希望这可以帮助某人...

Hope this helps someone...

这篇关于状态栏框架保持纵向,并遮住window.view的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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