【问题标题】:iOS Hidding status bar on a modal viewiOS隐藏模式视图上的状态栏
【发布时间】:2014-06-11 09:10:19
【问题描述】:

我正在尝试在屏幕上显示完整图像,通过推送模式视图,使用完整图像,我成功地做到了没有问题,但由于某种原因我无法隐藏模式上的状态栏,我我正在从集合视图的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 文件中,但什么也没发生。

【问题讨论】:

    标签: ios iphone statusbar presentmodalviewcontroller


    【解决方案1】:

    首先在你的info.plist视图中设置基于控制器的状态栏外观等于no,然后在你想要隐藏或不隐藏状态栏的地方使用:

    [[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationFade];
    
    [[UIApplication sharedApplication] setStatusBarHidden:NO
                                            withAnimation:UIStatusBarAnimationFade];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 2014-02-08
      • 2020-02-20
      • 1970-01-01
      • 2013-01-11
      • 2014-02-21
      相关资源
      最近更新 更多