-
-
Save situee/6723108 to your computer and use it in GitHub Desktop.
| //viewDidload | |
| if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { | |
| // iOS 7 | |
| [self prefersStatusBarHidden]; | |
| [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; | |
| } else { | |
| // iOS 6 | |
| [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
| } | |
| // Add this Method | |
| - (BOOL)prefersStatusBarHidden | |
| { | |
| return YES; | |
| } |
https://devforums.apple.com/message/888605#888605
by Tobias Arends
There are two different cases depending on the value of View controller-based status bar appearance in your info.plist. The default value is YES.
First Case:
Set View controller-based status bar appearance in your info.plist to NO.
You can use:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
You would Implement the following to achieve the hidden statusBar:
-(void)takePhotoPressed{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
return;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissViewControllerAnimated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}];
}
Second Case:
If you set View controller-based status bar appearance in your info.plist to YES. (Or you don't set it at all. It will default to YES)
This seems to be a very bad idea. But it does work.
Create a Category on UIViewController and override prefersStatusBarHidden to always return YES.
You can still override it to return NO in every ViewController in which you want to display the StatusBar.
iOS7 hide status bar; "prefersStatusBarHidden" is callback (delegate) method