Geen omschrijving

ProfileViewController.swift 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // ProfileViewController.swift
  3. // EncuestaMarle
  4. //
  5. // Created by Tatiana Castro on 5/21/19.
  6. // Copyright © 2019 Marle. All rights reserved.
  7. //
  8. import UIKit
  9. import ResearchKit
  10. class ProfileViewController: UIViewController {
  11. @IBOutlet weak var doneButton: UIButton!
  12. @IBAction func donePressed(_ sender: Any) {
  13. doneButton.isHidden = true
  14. doneButton.isEnabled = false
  15. if let viewWithTag = self.view.viewWithTag(1) {
  16. viewWithTag.removeFromSuperview()
  17. } else {
  18. print("error dismissing viewWithTag!")
  19. }
  20. }
  21. @IBAction func see_consent(_ sender: Any) {
  22. var docURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last as NSURL?
  23. docURL = docURL?.appendingPathComponent("ConsentDocument.pdf") as NSURL?
  24. let webView = WKWebView(frame: UIScreen.main.bounds)
  25. webView.tag = 1
  26. view.addSubview(webView)
  27. webView.navigationDelegate = self as? WKNavigationDelegate
  28. webView.load(URLRequest(url: docURL! as URL))
  29. doneButton.isHidden = false
  30. doneButton.isEnabled = true
  31. func removeWebView() {
  32. webView.removeFromSuperview()
  33. }
  34. // func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
  35. // switch reason {
  36. // case .completed:
  37. // let result = task.result
  38. // if let stepResult = result.stepResultForStepIdentifier("ConsentReviewStep"),
  39. // let signatureResult = stepResult.results?.first as? ORKConsentSignatureResult {
  40. // signatureResult.applyToDocument(consentDocument)
  41. //
  42. // consentDocument.makePDF { (data, error) -> Void in
  43. // let tempPath = NSTemporaryDirectory() as NSString
  44. // let path = tempPath.appendingPathComponent("signature.pdf")
  45. // data?.writeToFile(path, atomically: true)
  46. // print(path)
  47. // }
  48. //
  49. // }
  50. //
  51. // default:
  52. // break
  53. // }
  54. // }
  55. }
  56. // func taskViewController(_ taskViewController: ORKTaskViewController?, didFinishWith reason: ORKTaskViewControllerFinishReason) throws {
  57. // switch reason {
  58. // case ORKTaskViewControllerFinishReasonCompleted:
  59. // var signatureResult = task.result.stepResult(forStepIdentifier: "consentReviewIdentifier").firstResult() as? ORKConsentSignatureResult
  60. // if signatureResult?.signature.signatureImage != nil {
  61. // signatureResult?.signature.title = "\(signatureResult?.signature.givenName ?? "") \(signatureResult?.signature.familyName ?? "")"
  62. // signatureResult?.apply(toDocument: consentDocument)
  63. //
  64. // consentDocument.makePDF(withCompletionHandler: { pdfFile, error in
  65. // var paths = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)
  66. // var filePath = URL(fileURLWithPath: paths[0]).appendingPathComponent("Consent.pdf").absoluteString
  67. // try? pdfFile?.write(toFile: filePath, options: .atomic)
  68. // })
  69. // }
  70. // default:
  71. // break
  72. // }
  73. // }
  74. override func viewDidLoad() {
  75. super.viewDidLoad()
  76. doneButton.isHidden = true
  77. doneButton.isEnabled = false
  78. // Do any additional setup after loading the view.
  79. }
  80. /*
  81. // MARK: - Navigation
  82. // In a storyboard-based application, you will often want to do a little preparation before navigation
  83. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  84. // Get the new view controller using segue.destination.
  85. // Pass the selected object to the new view controller.
  86. }
  87. */
  88. }