QLPreviewController中导航栏被状态栏覆盖问题的解决方案

3

我第一次使用 QLPreviewController,并遇到了导航栏被状态栏遮挡的问题。以下是我遇到此问题的步骤:

  1. 点击 UI 以模态方式启动 QLPreviewController。这里工作正常。我看到导航栏和状态栏正确对齐。
  2. 在 QLPreviewController 中加载的视图中进行点击。导航栏被隐藏。
  3. 再次在 QLPreviewController 中加载的视图内进行点击。导航栏显示,并被状态栏遮挡。请参见附加的截屏。

你有什么想法,可能出了什么问题吗?

PS:这只发生在横屏模式下,在纵向模式下它可以正常工作。

这是我的代码:

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

QLPreviewController代理方法:

- (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个回答

11

对我来说有效:

- (BOOL)prefersStatusBarHidden {
    return NO;
}

2

通过在info.plist中添加一个UIViewControllerBasedStatusBarAppearance布尔键,并将值设置为“NO”,解决了问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接