2017-03-20 110 views
1

我有iCloud的文件導入 我得到空的選項我選擇從(iCloud中,谷歌驅動器,Dropbox的...等等) 我有iCloud的驅動器和數據導入的地方後一個問題權利是對UIDocumentMenuViewController空白選項

那麼,什麼是錯的代碼或者是有關於設置的任何地方都可能導致此問題?

這裏是代碼

@IBAction func selectionButtonAction(_ sender: Any) { 

     let types = [kUTTypePDF as String ,kUTTypePNG as String, kUTTypeImage as String,kUTTypeJPEG as String] 
     UINavigationBar.appearance().isTranslucent = true 
     let documentMenu = UIDocumentMenuViewController(documentTypes: types, in: .import) 
     documentMenu.delegate = self 
     self.viewController?.present(documentMenu, animated: true, completion: nil) 
    } 

    func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) { 
     documentMenu.delegate = self 
     self.viewController?.present(documentMenu, animated: true, completion: nil) 
    } 


    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) { 
     if controller.documentPickerMode == .import { 
// do staff 
     } 
    } 

這是我得到當我運行iOS上的10

應用程序時,我按選擇文件

When i Press choose File

然後按在iCloud上

After pressing on iCloud

這就是我得到的,如果我上運行的iOS 9應用程序:

That's what I get if I run the app on iOS 9


我敢肯定,我有數據有喜歡這裏的icloud的驅動程序

Dirve Data

而權利

enter image description here

回答

0

我有同樣的問題,試圖呈現UIDocumentMenuViewController的已使用實例時。 我懶洋洋地實例化這樣的:

lazy var documentMenuController: UIDocumentMenuViewController = { 
    let controller = UIDocumentMenuViewController(documentTypes: ["com.adobe.pdf"], in: .import) 
    controller.delegate = self 
    return controller 
}() 

其中,除了第一次每次產生這個錯誤。

所以我改變了代碼,以這樣的:

var documentMenuController: UIDocumentMenuViewController { 
    let controller = UIDocumentMenuViewController(documentTypes: ["com.adobe.pdf"], in: .import) 
    controller.delegate = self 
    return controller 
} 

要對物業的每次訪問獲取新的實例。