我试图在屏幕上显示完整的图像,通过推动模态视图,使用完整的图像,我设法做到这一点没有问题,但由于某种原因我无法隐藏模态上的状态栏,我我在集合视图的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];
}
我还尝试添加:
-(BOOL)prefersStatusBarHidden {
return YES;
}
在Modal .m文件中,但什么也没发生。
答案 0 :(得分:0)
首先在您的info.plist
基于视图控制器的状态栏中设置状态栏等于否,而不是在下面使用状态栏隐藏与否:
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
[[UIApplication sharedApplication] setStatusBarHidden:NO
withAnimation:UIStatusBarAnimationFade];