[英]iOS Hidding status bar on a modal view
I'm trying to display a full image on screen, by pushing a modal view, with the full image, i managed to do that with no problem, but for some reason i cannot hide the status bar on the modal, i'm presenting the modal from a didSelectItemAtIndexPath
of a collection view, i'm trying to hide the status bar, before calling the presentViewController
, here's the code: 我试图通过推动模态视图在屏幕上显示完整图像,并使用完整图像,但我设法做到了这一点没有问题,但是由于某种原因,我无法隐藏模态上的状态栏,来自集合视图的
didSelectItemAtIndexPath
的模态,在调用presentViewController
之前,我试图隐藏状态栏,这是代码:
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSArray *infoPhoto = self.imagesFromCD[indexPath.row];
// NSLog(@"Info photos = %@", infoPhoto);
NSString *imageName = [[self.imagesFromCD valueForKey:@"imgNameCD"]objectAtIndex:indexPath.row];
UIImage *imageToPass = [self getImageFromDocuments:imageName];
displayImageViewController *displayVC = [[displayImageViewController alloc]init];
displayVC.modalPresentationStyle = UIModalPresentationCustom;
displayVC.transitioningDelegate = self;
displayVC.foto = infoPhoto;
displayVC.imageToDisplay = imageToPass;
UIApplication *myapp = [UIApplication sharedApplication];
[myapp setStatusBarHidden:YES withAnimation:YES]; // Heres where the bar should be hidden.
[self presentViewController:displayVC animated:YES completion:nil];
}
I also tried to add the: 我还尝试添加以下内容:
-(BOOL)prefersStatusBarHidden {
return YES;
}
Inside the Modal .m file, but nothing happened. 在Modal .m文件中,但是什么也没发生。
First of all set in your info.plist
View controller-based status bar appearance is equal to no and than use below where ever you want to status bar hidden or not: 首先,在
info.plist
设置基于视图控制器的状态栏外观等于no,然后在要隐藏状态栏或不隐藏状态栏的任何位置以下使用:
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
[[UIApplication sharedApplication] setStatusBarHidden:NO
withAnimation:UIStatusBarAnimationFade];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.