daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top