Skip to content

Instantly share code, notes, and snippets.

@richo
Created July 10, 2019 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richo/be54f285572f48dc0ae31dd0390eb46c to your computer and use it in GitHub Desktop.
Save richo/be54f285572f48dc0ae31dd0390eb46c to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// test
//
// Created by richö butts on 7/8/19.
// Copyright © 2019 richö butts. All rights reserved.
//
import UIKit
import MobileCoreServices
class ViewController: UIViewController , UIDocumentPickerDelegate {
@IBAction func BUTTAN(_ sender: Any) {
let importMenu = UIDocumentPickerViewController(documentTypes: [String(kUTTypeText)], in: .open)
importMenu.delegate = self
importMenu.modalPresentationStyle = .formSheet
print("Presenting the thing")
self.present(importMenu, animated: false, completion: nil)
print("Presented the thing")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let myURL = urls.first else {
return
}
print("import result : \(myURL)")
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("view was cancelled")
dismiss(animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment