Hiding iPhone Status Bar pulls my tableViews up by 20px
- by JustinXXVII
When doing an asynchronous HTTP request, I hide the iPhone status bar and animate in my own custom UIViewController to show upload status. So instead of seeing signal strength, carrier, time and battery life, the user gets messages based on the progress of the HTTP request. My status bar is exactly 20px high, and fits nicely where the status bar used to be. When the HTTP activity is done, the custom view animates out and the iPhone status bar animates back in.
I would like to just avoid hiding the iPhone status bar completely, and instead bring my custom view ON TOP of the status bar. Currently, if I invoke my custom view animation and keep the iPhone status bar set to visible, my custom view is behind it.
This is the code I have:
-(void) animateStatusBarIn {
CGRect statusFrame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
UploadStatusBar *statusView = [[UploadStatusBar alloc] initWithNibName:@"UploadStatusBar" bundle:nil];
self.status = statusView;
[statusView release];
status.view.frame = statusFrame;
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[window addSubview:status.view];
[UIView beginAnimations:@"slideDown" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void) animateStatusBarOut {
[UIView beginAnimations:@"slideUp" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void)animationFinished:(NSString *)name {
if ([name isEqualToString:@"slideDown"]) {
}
if ([name isEqualToString:@"slideUp"]) {
[[UIApplication sharedApplication]setStatusBarHidden:NO animated:YES];
[status.view removeFromSuperview];
}
}
Without the [[UIApplication sharedApplication]setStatusBarHidden:YES animated:YES]
you can't see my custom view. How can I get my custom view to just appear on top of the status bar so I don't have to hide it?
Thank you!