iPhone UIViewController进入状态栏 [英] iPhone UIViewController goes under status bar

查看:114
本文介绍了iPhone UIViewController进入状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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屋!

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