PictureViewController.swift 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // Test3ViewController.swift
  3. // MCPlus
  4. //
  5. // Created by seo ha on 30/01/2019.
  6. // Copyright © 2019 KangSH. All rights reserved.
  7. //
  8. import UIKit
  9. import Photos
  10. import ReactiveCocoa
  11. import ReactiveSwift
  12. class PictureViewController: UIViewController {
  13. @objc var callBack:(([String:String])->Void)?
  14. var user:User?
  15. @IBOutlet weak var cameraContainer: UIView!
  16. @IBOutlet weak var gallaryContainer: UIView!
  17. static var patientId = MutableProperty<String?>(nil)
  18. static var patientNm = MutableProperty<String?>(nil)
  19. static var ageGender = MutableProperty<String?>(nil)
  20. }
  21. extension PictureViewController{
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. PictureViewController.patientId.value = user?.patientId
  25. PictureViewController.patientNm.value = user?.patientNm
  26. PictureViewController.ageGender.value = "\(user?.age ?? "") / \(user?.gender ?? "")"
  27. }
  28. func scanAction(){
  29. let alert = UIAlertController(title: "선택하세요", message: "", preferredStyle: .actionSheet)
  30. alert.addAction(UIAlertAction(title: "카메라", style: .default, handler: self.cameraAction))
  31. alert.addAction(UIAlertAction(title: "갤러리", style: .default, handler: self.gallaryAction))
  32. // show action sheet
  33. if let popoverController = alert.popoverPresentationController {
  34. popoverController.sourceView = self.view
  35. popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
  36. popoverController.permittedArrowDirections = []
  37. }
  38. self.present(alert, animated: true, completion: nil)
  39. }
  40. //커스텀 카메라 호출
  41. func cameraAction(action:UIAlertAction?){
  42. self.cameraContainer.isHidden = false
  43. self.gallaryContainer.isHidden = true
  44. }
  45. //포토 갤러리 호출
  46. func gallaryAction(action:UIAlertAction?){
  47. self.cameraContainer.isHidden = true
  48. self.gallaryContainer.isHidden = false
  49. }
  50. }