ios 7 document interaction controller hide status bar

| | August 18, 2015

In my iOS app i’ve hidden the status bar with this code in each ViewController:

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

In a view I need to use a UIDocumentInteractionController, but when it comes up, the status bar appears, is there a way to keep it hidden?

Thanks in advance

2 Responses to “ios 7 document interaction controller hide status bar”

  1. Use a combination of the following code and the code from iOS:

    - (UIViewController *) documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *) controller {
      // hack to keep status bar visible
      [[NSOperationQueue mainQueue] addOperationWithBlock:
        ^{
          [[UIApplication sharedApplication] setStatusBarHidden:NO];
      }];
      return self;
    }
    

    combined with

    - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller {
      [[UIApplication sharedApplication] setStatusBarHidden:YES];
    }
    
  2. Set documentController.delegate to self and use

    - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller {
        [[UIApplication sharedApplication] setStatusBarHidden:YES];
    }
    

Leave a Reply