1

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!

0

2 Answers 2

2

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); 
Sign up to request clarification or add additional context in comments.

Comments

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.... 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.