首页 > 解决方案 > UIDocumentPickerViewController 滚动视图与顶部导航栏重叠

问题描述

我正在尝试以模态方式显示 UIDocumentPickerViewController。它显示,但 UIDocumentPickerViewController 内的滚动视图没有从顶部显示某些部分,我必须向下滚动才能看到内容,一旦发布,再次回到顶部。图片(见图)。

这就是我正在尝试的方式!

let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.image", "public.audio", "public.movie", "public.text", "public.item", "public.content", "public.source-code"],
                                                                                          in: .import)

        if #available(iOS 11.0, *) {
            documentPicker.allowsMultipleSelection = true
        } else {
            // Fallback on earlier versions
        }

        self.present(documentPicker, animated: true,
                     completion: nil)

标签: uiscrollviewuinavigationcontrollerios11uidocumentpickerviewcontroller

解决方案


将 uinavigation bar 外观全局设置为 false 解决了该问题:

UINavigationBar.appearance().isTranslucent = false

但这似乎仍然是 hack,因为它会影响 isTranslucent 需要“真实”的应用程序的其他区域。

如果有人找到更好的解决方案,请更新。:)


推荐阅读