0

I am new to iOS development. I want the status bar hidden ONLY when I initiate camera so that the camera controls doesn't overlap with the status bar. I found solutions to adding this line:

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

Where should I put? I tried to add inside my -(IBAction)OpenCamera{} and - (void)viewDidLoad{} but both doesn't work.

Thanks for help!

2 Answers2

1

If you are using the latest SDK - Xcode 5 - then you might need to add the View-controller status bar appearance boolean to your application .plist

( screen attached ) enter image description here

I'm pretty sure it should be set to NO in order for you to be able to dynamically control the appearance. Also you just need:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

or

[[UIApplication sharedApplication] setStatusBarHidden:NO];

I think withAnimation is deprecated

BenMorel
  • 34,448
  • 50
  • 182
  • 322
dijipiji
  • 3,063
  • 1
  • 26
  • 21
  • After I set status bar is initially hidden to NO, where should I put that line? I tried again but it doesn't work. – user2898314 Oct 28 '13 at 16:38
  • Its a new plist item: View-controller status bar appearance – dijipiji Oct 28 '13 at 16:40
  • I added a new plist item called "status bar is initially hidden" and set boolean to NO. Is that what you mean? What about the next step, I mean where should I put [[UIApplication sharedApplication] setStatusBarHidden:YES]; ? – user2898314 Oct 28 '13 at 16:45
  • In your plist on iOS 7 ( Xcode 5 ) the very last item is View-controller status bar appearance ! – dijipiji Oct 28 '13 at 16:46
1

for hide status bar in iOS 7 try to add this:

- (IBAction)takeCamera {
[UIApplication sharedApplication].statusBarHidden = YES;

 BOOL cameraIsShow = YES   //custom boolean
}

- (BOOL)prefersStatusBarHidden {

  if(cameraIsShow == YES) {
    return YES;
 }
  else return NO;
}
Ilario
  • 5,979
  • 2
  • 32
  • 46