For the life of me, I cannot figure out how to get rid of the white bar at the top of my app.
http://cl.ly/image/3Z2I1x0H3H17
I am currently using a navigation controller as the root view. I've also tried just having a UIViewController as the root view.
In the first UIViewController I have tried:
- (void)viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:YES animated:NO];
}
This does nothing.
I have also tried:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Which hides the status icons (battery, cell connection indicator).
But really, I just want all that white space gone.
Try:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Or set Status Bar to 'None' in the XIB.
In viewDidLoad add this code:
//checks if device is running iOS 7 (or newer) or iOS 6 (or older)
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
Then add this method:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Related
I'm using an ad client in my project. The Ad client makes the application's status bar hidden. Can I do something to force the application to show status bar?
some code in objective C because i know only objective C
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Hide the status bar
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)])
{
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
}
else
{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
}
- (BOOL)prefersStatusBarHidden
{
return NO;
}
I want to disable navigation bar animation when page change.,
root viewController
- (BOOL)prefersStatusBarHidden{
return YES;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];,
}
pushed viewController
- (BOOL)prefersStatusBarHidden{
return NO;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];,
}
If both pages statusBarHidden is equal to NO or YES this method work but when i disable one of them a problem occurs. I could not upload image because of my reputation very low please check link for image.
https://www.facebook.com/photo.php?fbid=154038544933435&set=a.154038594933430.1073741827.100009818700445&type=1&theater
you should used this it work for me on tab gesture
NSTimer *timer;
if([UIApplication sharedApplication].statusBarHidden == YES)
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
timer= [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:#selector(hideStatusbar) userInfo:nil repeats:NO];
}
calling methods
-(void)hideStatusbar
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
Implementing prefersStatusBarHidden should do the trick. No need to override viewWillAppear:animated, because iOS animates automatically from one status bar state to the next.
Be sure to set "View controller-based status bar appearance" in your Info.plist to YES.
As far as the navigation bar is concerned. If you use storyboards and use Segueues you can transition from one Navigation Controller to the another. If navigation Controller A has a visible Navigation Bar and Navigation Controller B has a hidden Navigation Bar, iOS will automatically animate the Navigation Bar away for you.
I have a signup form that pops up when a button is tapped.
My aim is to hide the status bar when this modal is popped up.
Here is my code:
- (IBAction)tappedJoinButton:(id)sender {
if (![PFUser currentUser]) {
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate
// Present the sign up view controller
[self presentViewController:signUpViewController animated:YES completion:NULL];
}
}
I have set View controller-based status bar appearance to yes in my plist file. Now I'd like to choose where I hide the status bar. In this situation I'd like to hide it in the signUpViewController that pops up.
I haven't seen any answers on here showing how to hide it in a pushed view controller.
How do I achieve this?
Kind regards
If you want to hide status bar for only one ViewController the do this:
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (void)viewWillDisappear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[super viewWillDisappear:animated];
}
For your case it will be in PFSignUpViewController.
Hope this helps .. :)
Try this code
in viewDidload of PFSignUpViewController
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
paste this function in controller
- (BOOL)prefersStatusBarHidden {
return YES;
}
you lust like ....
if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
{
[[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
}
Write this in your viewWillAppear...
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Or try This method ....
-(void)navigationController:(UINavigationController *)
navigationController willShowViewController:(UIViewController *)
viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
Add this "View controller-based status bar" appearance in the plist and set NO
[[UIApplication sharedApplication] setStatusBarHidden:YES];
i want to hide status bar hidden in both ios 6.0 and ios 7.0.
please can you explain any common method which work in both ios version for ios.
please provide solution :-
thanks.
Update In Plist add these property.
Status bar is initially hidden = YES
View controller-based status bar appearance = NO
Programatically
- (void)viewDidLoad {
[super viewDidLoad];
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)])
{
[self prefersStatusBarHidden];
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
}
else
{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
} }
// add this too
- (BOOL)prefersStatusBarHidden {
return YES; }
I hid status bar in my app by setting [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; and by this code:
- (BOOL)prefersStatusBarHidden
{
return YES;
}
By when I show the MPMediaPickerController modal with [self presentViewController:mpMediaPlayerController animated:YES completion:^{}];, the status bar is being show again.
How can I hide it?
Subclass the MPMediaPickerController and add:
- (BOOL)prefersStatusBarHidden {
return YES;
}
After getting back from MPMediaPlayerController again hide status bar in ViewWillAppear method
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Hope it will work.