我試圖把一個documentPicker從iCloud獲取文件,但實際上我的應用程序打開documentMenu導入文件(iCloud,Dropbox),當我選擇iCloud時,我提出了文件選擇器與我的文件。當我委派文件documentPicker(_ ...)[documentPicker.delegate = self.delegate]功能不會被調用,因爲我的課不符合協議DocumentPickerDelegate無法工作後更新到SWIFT 3
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)
}
}
我有強制性和UIDocumentPickerDelegate的可選方法,但它不工作,因爲你可以在下面的圖片看到
這是我的第一個iOS應用程序,希望你能幫助我。
沒有 「你可以在圖像的下方看到」 有。 – Gruntcakes
請通過複製和粘貼相關代碼來對您的問題進行編輯,並清楚說明哪些部分有效,哪些部分沒有。 – rmaddy
謝謝。我的錯。圖片已更新 –