UIDocumentPickerViewController在底
2023-09-06 本文已影响0人
贵叔勇闯天涯
问题发现:
- 在实现调取iPhone本地(ICould)文件时代码如下:
func selectUploadFileFromICouldDrive(vc: UIViewController) {
let documentTypes = ["public.item",
"public.content",
"public.text",
"public.source-code",
"public.image",
"public.audiovisual-content",
"com.adobe.pdf",
"com.apple.keynote.key",
"com.microsoft.word.doc",
"com.microsoft.excel.xls",
"com.microsoft.powerpoint.ppt"]
let documentVC = UIDocumentPickerViewController(documentTypes: documentTypes, in: .open)
documentVC.delegate = self
documentVC.modalPresentationStyle = .fullScreen
documentVC.allowsMultipleSelection = false
vc.present(documentVC, animated: true, completion: nil)
}
-
运行时发现页面底部出现了灰色区域
image.png -
进而研究发现,首页有TabBar的页面也都出现了问题:
[图片上传中...(image.png-772a52-1694054239879-0)]
1432382-0dcd43f4ff6a0888 (1).png
解决方案:
- 首先感谢UIDocumentPickerViewController在底部显示空白区域一文带来的思路
- 在代码中找到了UITabBar.appearance()的定制导致的问题:
UITabBar.appearance().backgroundColor = UIColor.white
UITabBar.appearance().backgroundImage = UIImage.colorToImage( UIColor.white)
- 只需要将以下代码注释即可
# UITabBar.appearance().backgroundImage = UIImage.colorToImage( UIColor.white)
- 注意:当注释了上诉代码后,首页TabBar内的VC的视图高度会有变化
- 更多有关TabBar相关的定制请移步:
iOS------主题设置-->Appearance