3
votes

I have been dealing with QLPreviewController for the first time and running into an issue of navigation bar getting overlapped by status bar. Below are the steps I ran into this issue with:

  1. Tap on UI to launch the QLPreviewController modally. This works fine here. I see nav bar and status bar properly aligned.
  2. Tap inside the view loaded in QLPreviewController. Navigation bar is hidden.
  3. Tap again inside the view loaded in QLPreviewController. Navigation bar is shown back with nav bar overlapped by status bar. Please see the attached screenshot.

Any idea what could be wrong here?

PS: This is happening only in Landscape mode. Portrait mode its working fine.

This is my code:

QLPreviewController *aQLPreviewController = [[QLPreviewController alloc] init];
aQLPreviewController.dataSource = self;
aQLPreviewController.delegate = self;
[myViewController presentViewController:aQLPreviewController animated:YES completion:NULL];

QLPreviewController delegate methods:

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *)iController {
    return 1;
}


- (id <QLPreviewItem>) previewController: (QLPreviewController *) iController previewItemAtIndex: (NSInteger) iIndex {
    if (iIndex == 0) {
        return self.myURL;
    } else {
        return nil;
    }
}


- (void)previewControllerDidDismiss:(QLPreviewController *)iController {
    self.myURL = nil;
}

enter image description here

2

2 Answers

11
votes

It works for me:

- (BOOL)prefersStatusBarHidden {
    return NO;
}
2
votes

Got it fixed by adding a UIViewControllerBasedStatusBarAppearance Boolean key in info.plist and assign value “NO”.