当我将一个视图(view1)添加到另一个视图(view2)时,我发现一个错误:如果状态栏没有隐藏,添加视图(view1)后,下面的view1可以出现20像素高的空栏。如果状态栏被隐藏,这种现象就消失了。谁能帮我解决这个问题。想你!
问问题
1788 次
2 回答
2
只需检查状态栏是否隐藏并通过添加 20 像素来调整第二个 UIView 的框架
if([[UIApplication sharedApplication] isStatusBarHidden])
view2.frame = CGRect(x,y,width,height);
else
view2.frame = CGRect(x,y+20,width,height);
于 2011-03-19T23:24:15.607 回答
0
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....
于 2011-06-20T13:53:45.780 回答