Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBAction func cameraButton(_ sender: Any) {
- let imagePicker = UIImagePickerController()
- imagePicker.delegate = self
- let alertController = UIAlertController(title:nil, message: nil, preferredStyle:.actionSheet)
- let cancelAction = UIAlertAction(title: "Camera is not available", style: .cancel, handler: nil)
- alertController.addAction(cancelAction)
- if UIImagePickerController.isSourceTypeAvailable(.camera){
- let cameraAction = UIAlertAction(title:"Take Photo", style:.default, handler:{(_) in imagePicker.sourceType = .camera
- self.present(imagePicker, animated: true, completion: nil)
- })
- alertController.addAction(cameraAction)
- }
- present(alertController, animated: true, completion: nil)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement