Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, December 21, 2015

How to hide iOS 7 status bar

How to hide iOS 7 status bar


In my iOS video app status bar is hidden in some view controllers. I have done this using following code.

[[UIApplication sharedApplication] setStatusBarHidden:YES];  
  • It works for iOS 5 and iOS 6 , but not in iOS 7.

  • I tried with this in particular view controller,

Eg:

-(BOOL)prefersStatusBarHidden { return YES; }  

It works well, but I cant show status bar again in the parent view controller.

Answer by Rajneesh071 for How to hide iOS 7 status bar


You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".

enter image description here

Answer by Manju for How to hide iOS 7 status bar


To hide your status bar in iOS7:

Open Your plist-file, then add a add a row called "View controller-based status bar appearance" and set its value to NO.

Answer by Gurumoorthy Arumugam for How to hide iOS 7 status bar


In the Plist add the following properties.

Status bar is initially hidden = YES    View controller-based status bar appearance = NO  

now the status bar will hidden.

Answer by Kemal Can Kaynak for How to hide iOS 7 status bar


Try that;

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];  

Answer by RIYAZ for How to hide iOS 7 status bar


To hide status bar in iOS7 you need 2 lines of code

  1. in application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write

     [[UIApplication sharedApplication] setStatusBarHidden:YES];  
  2. in info.plist add this

     View-Controller Based Status Bar Appearance = NO  

Answer by Hitesh Vaghela for How to hide iOS 7 status bar


Add following line in viewdidload

  [[UIApplication sharedApplication] setStatusBarHidden:YES                                          withAnimation:UIStatusBarAnimationFade];  

and add new method

  - (BOOL)prefersStatusBarHidden {            return YES;    }  

also change info.plist file View controller-based status bar appearance" = NO

its works for me

Answer by VietHung for How to hide iOS 7 status bar


From UIKit>UIApplication.h:

// Setting statusBarHidden does nothing if your application is using the default UIViewController-based status bar system.  @property(nonatomic,getter=isStatusBarHidden) BOOL statusBarHidden;  - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation NS_AVAILABLE_IOS(3_2);  

So should set View controller-based status bar appearance to NO

Answer by Shekhar Gupta for How to hide iOS 7 status bar


Add the following to your Info.plist:

UIStatusBarHidden    UIViewControllerBasedStatusBarAppearance    

Image

Answer by SVMRAJESH for How to hide iOS 7 status bar


Try this simple method:

- (void)viewWillAppear:(BOOL)animated  {      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];  }    - (void)viewWillDisappear:(BOOL)animated  {      [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];  }  

Answer by Kirill for How to hide iOS 7 status bar


For better understanding add some photos with comments:

App before any changes

enter image description here

Found in your Project Navigator folder named Supporting Files and click on *.plist file

enter image description here

After you will get different setting of your app showed. You need to add 2 keys UIStatusBarHidden and UIViewControllerBasedStatusBarAppearance. You can do this simply clicking on + button

enter image description here

After pressing + you can choose one of the key - just start to type.

Correct version:

enter image description here

And finally application after applying this changes:

enter image description here

Also, you can find alternative solution here

Answer by bLacK hoLE for How to hide iOS 7 status bar


You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".

Answer by smartbot for How to hide iOS 7 status bar


I did the following and it seems to work (even in iOS 8):

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated  {      if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {            [[UIApplication sharedApplication] setStatusBarHidden:YES];      }  }    - (BOOL)prefersStatusBarHidden {      return YES;  }  

Answer by smileBot for How to hide iOS 7 status bar


To answer the Susitha's question: use setNeedsStatusBarAppearanceUpdate. This will make a call to prefersStatusBarHidden to refresh with your desired status bar state. Try this:

    @property (nonatomic, getter=isHideStatusBar) BOOL hideStatusBar; // Give this a default value early        - (BOOL)prefersStatusBarHidden {          return self.isHideStatusBar;      }        - (void)someMethod {      // triggered by an event or user action      [self setHideStatusBar:YES];      [self setNeedsStatusBarAppearanceUpdate];      }  

If you want to see the status bar again, set your property hideStatusBar (or whatever you call it) to NO. Call preferStatusBarHidden indirectly by making another call to

[self setNeedsStatusBarAppearanceUpdate]  

Answer by Esq for How to hide iOS 7 status bar


Here is the Swift version (pre iOS9):

override func viewWillAppear(animated: Bool) {      super.viewWillAppear(animated)      UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.None)  }    override func viewWillDisappear(animated: Bool) {      super.viewWillDisappear(animated)      UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)  }  

This also works (iOS7+):

override func prefersStatusBarHidden() -> Bool {      return true  }  

You also need to call:

setNeedsStatusBarAppearanceUpdate()  

in say viewDidLoad().

Note that if you use a SplitView controller, or some other container view controller, you also need to have it return your class when its sent childViewControllerForStatusBarHidden. One way to do this is have a public weak var for say statusController, and return it in this overridden method.

Answer by Chris for How to hide iOS 7 status bar


  • UIApplication.setStatusBarX are deprecated as of iOS9
  • It's deprecated to have UIViewControllerBasedStatusBarAppearance=NO in your info.plist
  • So we should be using preferredStatusBarX in all our view controllers

But it gets more interesting when there's a UINavigationController involved:

  • If navigationBarHidden = true, the child UIViewController's preferredStatusBarX are called, since the child is displaying the content under the status bar.
  • If navigationBarHidden = false, the UINavigationController's preferredStatusBarX are called, after all it is displaying the content under the status bar.
  • The UINavigationController's default preferredStatusBarStyle uses the value from UINav.navigationBar.barStyle. .Default = black status bar content, .Black = white status bar content.
  • So if you're setting barTintColor to some custom colour (which you likely are), you also need to set barStyle to .Black to get white status bar content. I'd set barStyle to black before setting barTintColor, in case barStyle overrides the barTintColor.
  • An alternative is that you can subclass UINavigationController rather than mucking around with bar style.
  • HOWEVER, if you subclass UINavigationController, you get no control over the status bar if navigationBarHidden = true. Somehow UIKit goes direct to the child UIViewController without asking the UINavigationController in this situation. I would have thought it should be the UINavigationController's responsibility to ask the child >shrugs<.
  • And modally displayed UIViewController's only get a say in the status bar if modalPresentationStyle = .FullScreen.
  • If you've got a custom presentation style modal view controller and you really want it to control the status bar, you can set modalPresentationCapturesStatusBarAppearance = true.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.