2017-01-17 5 views
1

iCloudからカスタムアプリケーションでPDFファイルをアップロードしようとしています。しかし、アプリケーションからiCloudに移動すると、ドキュメントを選択することができないため、ドキュメントが無効になっているように見えます。ほとんどの説明のほとんどはObj-Cにありますので、私は正確に理解できませんでした。swift:iCloudsドキュメントがカスタムアプリケーションからロードされたときに無効になっているようです

ここで何が間違っていますか?これはswift2で私のコードです:他の多くのがありますが

@IBAction func handleImportPickerPressed(sender: AnyObject) { 

    let documentPicker = UIDocumentPickerViewController(documentTypes:["public.data", "public.text"],inMode: UIDocumentPickerMode.Import) 
    documentPicker.delegate = self 
    documentPicker.modalPresentationStyle = UIModalPresentationStyle.FormSheet 
    presentViewController(documentPicker, animated: true, completion: nil) 
} 

:彼らは無効です

import UIKit 
import MobileCoreServices 
class ViewController: UIViewController, UIDocumentPickerDelegate, UITextViewDelegate { 

    @IBOutlet weak var emailButton: UIButton! 
    @IBOutlet weak var UITextField: UITextView! 
    override func viewDidLoad() { 

     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 

    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 

    } 

    @IBAction func handleImportPickerPressed(sender: AnyObject) { 
     let documentPicker = UIDocumentPickerViewController(documentTypes: [kUTTypeText as NSString as String], inMode: .Import) 
     documentPicker.delegate = self 
     presentViewController(documentPicker, animated: true, completion: nil) 
    } 

    func documentPicker(controller: UIDocumentPickerViewController, didPickDocumentAtURL url: NSURL) { 


     print(url) 
    } 
+0

私はあなたを得なかった:) – Sam

+0

2回キャストしないでください!あなたはNSStringにkUTTypeTextをキャストして、それを再びStringにキャストしています。これは意味がありません。必要なタイプに一度だけ直接キャストしてください。 – Moritz

+0

ok私は[kUTTypeText as String]を行っています。でも同じ問題です – Sam

答えて

0

はあなたのiCloudを持っているドキュメントタイプのように、あなたのアールのselecting.Useドキュメントタイプながら、一致していないことを意味しドキュメントタイプ。無効になっているとは、あなたが渡しているの文書タイプでは読み取れないことを意味します。

関連する問題