iPhone UIViewController 进入状态栏 [英] iPhone UIViewController goes under status bar
问题描述
我有一个 UIView
和一个 UIController
视图.我的标准是 320x460 视图.在 applicationDidFinishLaunching
我做:
I have a UIView
and a UIController
view. My is standard a 320x460 view. In applicationDidFinishLaunching
I do:
[window addSubview:[controller view]];
奇怪的是 UIView
位于状态栏下方(就像缺少插座一样).但是,如果我将 iPhone 旋转到一边然后再旋转,它显示正常.
The weird thing is that the UIView
goes under the status bar (like there's missing outlet). However, if I rotate iPhone to the side and then back, it shows up ok.
这是预期的行为(我敢打赌我可以通过设置偏移量来修复它)还是我做错了什么?
Is this an expected behavior (I bet I can fix it by setting offset) or am I doing smth wrong?
推荐答案
我觉得你的问题是在给窗口添加视图的时候,需要注意状态栏的状态并进行补偿:
I think your problem is that when you add a view to a window, you need to be aware of the state of the status bar and compensate for it:
if showing the status bar :
[controller view].frame = CGRectMake(0, **20**, 320, 460);
else
[controller view].frame = CGRectMake(0, 0, 320, **480**);
这就是 IB 向您显示一个虚拟状态栏的原因.
this is why IB shows you a dummy status bar.
这篇关于iPhone UIViewController 进入状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!