iphone查看和状态栏

当我将一个视图(view1)添加到另一个视图(view2)时,我发现一个错误: 如果状态栏未隐藏,则在添加视图(view1)后,下图view1可以显示20像素高的空条。 如果隐藏状态栏,则此现象消失。 谁可以帮我解决这个问题。 想你!     
已邀请:
只需检查状态栏是否隐藏,并通过添加20像素来调整第二个UIView的帧
if([[UIApplication sharedApplication] isStatusBarHidden])
        view2.frame = CGRect(x,y,width,height);
    else
        view2.frame = CGRect(x,y+20,width,height);
    
作为一个更具体的例子,我有一个案例,在应用程序启动后,我实际上还没有准备好让用户看到屏幕上发生了什么。在这种情况下,我有一个仍在渲染的webview,所以我将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....
    

要回复问题请先登录注册