I've tried to put a documentPicker to get a file from iCloud but Actually my app opens the documentMenu to import a file (iCloud, Dropbox) and when I choose iCloud, I present the document picker with my files. When I've to delegate the file to documentPicker(_ ...) [documentPicker.delegate=self.delegate] function is never called because my class does not conform to protocol
import UIKit
class ImportKeyViewController: UIViewController{
@IBOutlet weak var openWithLabel: UILabel!
@IBOutlet weak var transparentBackgroundView: UIView!
@IBOutlet weak var iCloudButton: UIButton!
@IBOutlet weak var iTunesButton: UIButton!
weak var delegate : UIDocumentPickerDelegate?
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL){
print("Entre a documentPicker")
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("Sali a documentPicker")
}
override func viewDidLoad() {
super.viewDidLoad()
print("llegue")
setUpUI()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 0.1, animations: {
self.transparentBackgroundView.backgroundColor = UIColor(red: 220/255, green: 220/255, blue: 220/255, alpha: 0.7)
})
}
override func viewWillDisappear(_ animated: Bool) {
UIView.animate(withDuration: 0.1, animations: {
self.transparentBackgroundView.backgroundColor = UIColor.clear
})
}
@IBAction func closeButtonAction(_ sender: UIButton) {
let documentPicker = UIDocumentPickerViewController (documentTypes: ["public.text","public.content"], in: .import)
documentPicker.delegate? = self.delegate!
self.present(documentPicker, animated:true, completion: nil)
}
}
I've the obligatory and optional methods for UIDocumentPickerDelegate but it's not working as you can see in image below
This is my first iOS App, hope you can help me.