美文网首页
UIDocumentPickerViewController在底

UIDocumentPickerViewController在底

作者: 贵叔勇闯天涯 | 来源:发表于2023-09-06 10:43 被阅读0次

    问题发现:

    1. 在实现调取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)
        }
    
    1. 运行时发现页面底部出现了灰色区域


      image.png
    2. 进而研究发现,首页有TabBar的页面也都出现了问题:
      [图片上传中...(image.png-772a52-1694054239879-0)]


      1432382-0dcd43f4ff6a0888 (1).png

    解决方案:

    1. 首先感谢UIDocumentPickerViewController在底部显示空白区域一文带来的思路
    2. 在代码中找到了UITabBar.appearance()的定制导致的问题:
            UITabBar.appearance().backgroundColor = UIColor.white
            UITabBar.appearance().backgroundImage = UIImage.colorToImage( UIColor.white)
    
    1. 只需要将以下代码注释即可
    # UITabBar.appearance().backgroundImage = UIImage.colorToImage( UIColor.white)
    
    1. 注意:当注释了上诉代码后,首页TabBar内的VC的视图高度会有变化
    2. 更多有关TabBar相关的定制请移步:
      iOS------主题设置-->Appearance

    相关文章

      网友评论

          本文标题:UIDocumentPickerViewController在底

          本文链接:https://www.haomeiwen.com/subject/ebekvdtx.html