标签: uidocumentpicker

如何解决关闭文档选择器时出现的错误

设置文档选择器,用户可以从“文件应用程序”中选择 PDF 文件,并将其保存到我的应用程序文档文件夹中以在应用程序中使用。

打开文档选择器,选择文件 - 但关闭后出现以下错误:

“[DocumentManager] 视图服务确实终止并出现错误:Error Domain=_UIViewServiceErrorDomain Code=1 “(null)”UserInfo={Termminate=disconnect method}”

UIViewController代码:

import UIKit
import CoreData
import PDFKit
import MobileCoreServices
import UniformTypeIdentifiers


class AddDocumentViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIDocumentPickerDelegate {



@IBAction func chooseFile (_ sender: UIButton) {
    fileTypeSelectionInput = fileTypeSelection.selectedSegmentIndex
    
        var documentPicker: UIDocumentPickerViewController!
        if #available(iOS 14, *) {
            // iOS 14 & later
            let supportedTypes: [UTType] = [UTType.pdf]
            documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes)
        } else {
            // iOS 13 or older code
            let supportedTypes: [String] = [kUTTypeImage as String]
            documentPicker = …
Run Code Online (Sandbox Code Playgroud)

uidocument uidocumentpicker

5
推荐指数
0
解决办法
298
查看次数

标签 统计

uidocument ×1

uidocumentpicker ×1