我使用UIImagepickercontroller拍摄并选择现有的照片,当相机视图出现时,相机上的顶部被白色状态栏覆盖。如何删除状态栏或隐藏状态栏。他们中的许多人说这是一个ios 7错误,它已经在ios 7.1中修复了,但我仍然面临着这个问题。
这是我展示imagepickerController的代码
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = (id)self;
imagePicker.sourceType = (buttonIndex == actionSheet.firstOtherButtonIndex ?
UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary);
[self.viewController presentViewController:imagePicker animated:YES completion:nil]; 另外,我还尝试用下面的代码隐藏状态条
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}这
-(BOOL) prefersStatusBarHidden {
return YES;
}代表中的这个
[UIApplication ShareApplication]SetStatusbarHidden:YES];现在我正在使用ios8,这种行为在所有ios版本中都会发生。请帮帮我。
发布于 2014-10-06 11:01:31
实际上,问题是在我的rootview控制器中,我正在使用UIView创建一个Statusbar,并以编程方式设置其对景观和肖像的约束。
- (void)setTopBar {
if(topBar == nil && [[UIApplication sharedApplication] keyWindow] != nil) {
topBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
topBar.backgroundColor = navController.view.backgroundColor;
topBar.tag = topBarViewTag;
UIView *containerView = [[UIApplication sharedApplication] keyWindow];
[containerView addSubview:topBar];
[containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view(20)]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:@{@"view" : topBar}]];
[containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[view]|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:@{@"view" : topBar}]];
[containerView layoutSubviews];
}}
因此,当我在ViewwillAppear中评论上述方法时,状态栏中没有显示,所以问题在于我的代码。
如果有人面临同样的问题,我建议您查看一下RootViewcontroller,它可以导航到所有其他类。
https://stackoverflow.com/questions/25927744
复制相似问题