I have the following code
else {
if ([[UIApplication sharedApplication] isStatusBarHidden]) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
_navigationBar.hidden = NO;
_navigationControl.hidden = NO;
} else {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
_navigationBar.hidden = YES;
_navigationControl.hidden = YES;
}
}
If I compile it, it works fine in iOS6 but it doesn't in ios7. The navbar is meant to appear when the user taps on the screen.
Any idea?
Thanks!
In your info.plist file set the key, "View controller-based status bar appearance" to NO.
Related
I want to hide staus bar in single view controller but my code is not working.
I'm using the below code
-(BOOL)prefersStatusBarHidden
{
return YES;
}
&
-(void)viewWillApper:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
or
in
application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write
[[UIApplication sharedApplication] setStatusBarHidden:YES];
or
Add following line in viewdidload
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
and add new method
- (BOOL)prefersStatusBarHidden {
return YES;
}
if you have View controller-based status bar appearance set to YES in app's plist, put this code in the view controller:
- (BOOL)prefersStatusBarHidden {
return YES;
}
and if View controller-based status bar appearance is set to NO, do the following whenever you want to hide the status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
try this one it's help for me-:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
To hide status bar on a single VC:
1) Add this value to plist:
"View controller-based status bar appearance" and set it to "YES"
2) Add following to viewWillAppear:
[self prefersStatusBarHidden];
3) Add new method:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
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 read lot's of answers how to hide status bar on iPad in iOS 7.0 but nothing works. My app is an iPhone app only, and it's deployment target is set to 6.0 . On iPhone 6.0 , 7.0 and iPad 6.0 status bar is hidden, but on iPad with iOS 7.0 isn't.
Try:
Option1:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Use this code in the rootViewController of your app
Option 2:
In info.plist file add a row for "View controller-based status bar appearance" and set it to NO
Option 3:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Try these properties in the plist also for iPad 7.0
Status bar is initially hidden = YES
View controller-based status bar appearance = NO
Try if add this to hide the status bar if you use "View controller-based status bar appearance" to NO.
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application setStatusBarHidden:YES];
return YES;
}
I always use this snippet:
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]){
[self prefersStatusBarHidden];
}
else{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
[self setNeedsStatusBarAppearanceUpdate];
And implement this method:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Try adding this method to your ViewController , it worked for me
- (BOOL)prefersStatusBarHidden
{
return 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.