iPhone视图和状态栏

发布于 2024-10-22 04:25:46 字数 126 浏览 3 评论 0原文

当我将一个视图(view1)添加到另一个视图(view2)时,我发现一个错误: 如果状态栏没有隐藏,添加视图(view1)后,下面的view1会出现20像素高的空栏。 如果状态栏被隐藏,这种现象就会消失。 谁能帮我解决这个问题。 想你了!

When i add one view(view1) to another view(view2), i find a error:
If the status bar is not hidden, after add the view(view1), bellow view1 can appear 20 pixel hight null bar.
If the status bar is hidden, this phenomenon disappear.
Who can help me to resolve this question.
think you!

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

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

发布评论

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

评论(2

明月松间行 2024-10-29 04:25:46

只需检查状态栏是否隐藏并通过添加 20 个像素来调整第二个 UIView 的框架

if([[UIApplication sharedApplication] isStatusBarHidden])
        view2.frame = CGRect(x,y,width,height);
    else
        view2.frame = CGRect(x,y+20,width,height);

Just check if the statusbar is hidden and adjust the frame of your second UIView by adding 20 pixels

if([[UIApplication sharedApplication] isStatusBarHidden])
        view2.frame = CGRect(x,y,width,height);
    else
        view2.frame = CGRect(x,y+20,width,height);
弱骨蛰伏 2024-10-29 04:25:46

作为一个更具体的示例,我有一个情况,在应用程序启动后,我实际上还没有准备好让用户看到屏幕上发生的情况。在这种情况下,我有一个仍在渲染的 Web 视图,因此我将 Default.png 文件覆盖到我的视图上,而后台发生了一些垃圾。

// put the default image over the whole screen while we wait for the html to load
UIImageView * defaultImageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"Default.png"]] ;
[self.view addSubview:defaultImageView];  


// adjust for status bar
if(![[UIApplication sharedApplication] isStatusBarHidden]) {//http://stackoverflow.com/questions/5310975/iphone-view-and-statusbar
    CGRect imageRect = defaultImageView.frame;
    imageRect.origin.y = imageRect.origin.y - 20;
    defaultImageView.frame = imageRect;
  }

Now, later in the code, remove the subview....

As a more concrete example, I have a case where, after the application has launched, I'm actually not quite ready for the user to see what is happening on the screen. In this case, I have a webview that is still rendering, so I overlay the the Default.png file onto my view while some junk happens in the background.

// put the default image over the whole screen while we wait for the html to load
UIImageView * defaultImageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"Default.png"]] ;
[self.view addSubview:defaultImageView];  


// adjust for status bar
if(![[UIApplication sharedApplication] isStatusBarHidden]) {//http://stackoverflow.com/questions/5310975/iphone-view-and-statusbar
    CGRect imageRect = defaultImageView.frame;
    imageRect.origin.y = imageRect.origin.y - 20;
    defaultImageView.frame = imageRect;
  }

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