Post

Replies

Boosts

Views

Activity

Open a specific folder using UIDocumentPickerViewController
I'm using UIDocumentPickerViewController to import document to my app from OneDrive and I want to show the OneDrive folder every time I use UIDocumentPickerViewController instead of the last folder I opened. Is it possible? Can I use pickerController.directoryURL ? And how to get folder URL of OneDrive? class ViewController: UIViewController, DocumentDelegate {   var picker: DocumentPicker?       override func viewDidLoad() {     super.viewDidLoad()     picker = DocumentPicker(presentationController: self, delegate: self)   }   @IBAction func create_picker(_ sender: Any) {     picker?.presentDocumentPicker()   }       func didPickImage(image: UIImage?) {} } protocol DocumentDelegate: AnyObject {   func didPickImage(image: UIImage?) } class DocumentPicker: NSObject {   private var pickerController: UIDocumentPickerViewController?   private weak var presentationController: UIViewController?   private weak var delegate: DocumentDelegate?   init(presentationController: UIViewController,      delegate: DocumentDelegate) {     super.init()     self.presentationController = presentationController     self.delegate = delegate   }       func presentDocumentPicker() {     pickerController = UIDocumentPickerViewController(forOpeningContentTypes: [.image])     if let pickerController = pickerController {       pickerController.delegate = self       pickerController.allowsMultipleSelection = false       presentationController?.present(pickerController, animated: true)     }   } } extension DocumentPicker: UIDocumentPickerDelegate {   func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {     guard let url = urls.first else { return }     print(url)   } }
1
0
755
Nov ’21
WidgetKit configuration display name?
I having a question about widget's configuration: configurationDisplayName and description. Can I change this value by an action from main app, and if I can, how can I do that? For example I tap a button and widget's name change.   var body: some WidgetConfiguration {     return StaticConfiguration(kind: kind, provider: Provider()) { entry in       WidgetView()     }     .configurationDisplayName("My Widget")     .description("This is my widget")   } Thank you.
5
1
2.3k
Sep ’20