简体   繁体   English

导航栏在QLPreviewController中与状态栏重叠

[英]Navigation bar getting overlapped by status bar in QLPreviewController

I have been dealing with QLPreviewController for the first time and running into an issue of navigation bar getting overlapped by status bar. 我第一次处理QLPreviewController并遇到状态栏重叠的导航栏问题。 Below are the steps I ran into this issue with: 以下是我遇到此问题的步骤:

  1. Tap on UI to launch the QLPreviewController modally. 点击UI以模态方式启动QLPreviewController。 This works fine here. 这在这里工作正常。 I see nav bar and status bar properly aligned. 我看到导航栏和状态栏正确对齐。
  2. Tap inside the view loaded in QLPreviewController. 点击QLPreviewController中加载的视图内部。 Navigation bar is hidden. 导航栏被隐藏。
  3. Tap again inside the view loaded in QLPreviewController. 在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. PS:这仅在横向模式下发生。 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: 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;
}

在此输入图像描述

It works for me: 这个对我有用:

- (BOOL)prefersStatusBarHidden {
    return NO;
}

通过在info.plist中添加UIViewControllerBasedStatusBarAppearance布尔键并指定值“NO”来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM