Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. @IBAction func cameraButton(_ sender: Any) {
  2. let imagePicker = UIImagePickerController()
  3. imagePicker.delegate = self
  4.  
  5. let alertController = UIAlertController(title:nil, message: nil, preferredStyle:.actionSheet)
  6. let cancelAction = UIAlertAction(title: "Camera is not available", style: .cancel, handler: nil)
  7. alertController.addAction(cancelAction)
  8.  
  9. if UIImagePickerController.isSourceTypeAvailable(.camera){
  10. let cameraAction = UIAlertAction(title:"Take Photo", style:.default, handler:{(_) in imagePicker.sourceType = .camera
  11. self.present(imagePicker, animated: true, completion: nil)
  12.  
  13. })
  14. alertController.addAction(cameraAction)
  15. }
  16.  
  17. present(alertController, animated: true, completion: nil)
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement