Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Remove status bar programmatically

I have made an app that implements the iPhone's camera. When the user finishes picking their image, the status bar reappears! How would I make sure that the status bar stays hidden?

Here is my code:

-(IBAction)pickImage:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;

picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
background.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

}

If i am doing anything wrong, please point it out! Thanks, Rafee

like image 839
RafeeJ Avatar asked Mar 20 '12 21:03

RafeeJ


People also ask

Where is the status bar on iPhone?

The icons in the status bar at the top of the screen provide information about iPhone. On an iPhone with Face ID, there are additional status icons at the top of Control Center.

How do I hide my status bar on iPhone 7?

To completely hide it on the home screen, open up an app, such as Settings, and wait about three to four seconds. Press the home button again, and the status bar will be completely gone. The status bar will only be hidden on your home screen, so you'll still see it while using apps.

How do I hide status bar in SwiftUI?

Make sure your initial SwiftUI View is a Navigation view where you hide the status bar. Then if you navigate to a tab bar view or any subsequent views the status bar will be hidden.


2 Answers

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

You may opt for another animation style if at all.

like image 198
Hermann Klecker Avatar answered Oct 27 '22 00:10

Hermann Klecker


In iOS 7, there is a method on UIViewController, "prefersStatusBarHidden". To hide the status bar, add this method to your view controller and return YES:

- (BOOL) prefersStatusBarHidden
{
    return YES;
}
like image 28
Ulf Dahlén Avatar answered Oct 27 '22 00:10

Ulf Dahlén