Удалить программную строку состояния в imagePickerController IOS 7
Мне нужно удалить строку состояния, когда сделайте снимок y, попробуйте, но не работает.
[[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationSlide];
- (IBAction)botonCamara:(id)sender {
// Make sure camera is available
if ([UIImagePickerController
isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Camera Unavailable"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil, nil];
[alert show];
return;
}
if (imagePicker == nil)
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
}
[self presentViewController:imagePicker animated:YES completion:NULL];
}
#pragma mark - delegate methods
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
UIImageWriteToSavedPhotosAlbum (image, nil, nil , nil);
[self dismissViewControllerAnimated:YES completion:NULL];
}
Ответы
Ответ 1
Если вы хотите, чтобы строка состояния была скрыта полностью, выполните
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
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;
}
Ответ 2
Я пробовал много способов, и я думаю, что это самый простой способ скрывать строку состояния программно.
- (void)showStatusBar {
UIWindow *statusBarWindow = [(UIWindow *)[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
CGRect frame = statusBarWindow.frame;
frame.origin.y = 0;
statusBarWindow.frame = frame;
}
- (void)hideStatusBar {
UIWindow *statusBarWindow = [(UIWindow *)[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
CGRect frame = statusBarWindow.frame;
CGSize statuBarFrameSize = [UIApplication sharedApplication].statusBarFrame.size;
frame.origin.y = -statuBarFrameSize.height;
statusBarWindow.frame = frame;
}
My dev environment: XCode 6.6.1 на Yosemite 10.10.1., для iOS 8.1
Ответ 3
В панели состояния завершения блокировки showViewController скрыта и в завершении упреждающего контроля отображается строка состояния