Created
May 26, 2021 04:32
-
-
Save anupamchugh/eb4363e47edc817f8012011c9bb1c898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard UIImagePickerController.isSourceTypeAvailable(.camera) else { | |
presentPhotoPicker(sourceType: .photoLibrary) | |
return | |
} | |
let photoSourcePicker = UIAlertController() | |
let takePhoto = UIAlertAction(title: "Camera", style: .default) { [unowned self] _ in | |
self.presentPhotoPicker(sourceType: .camera) | |
} | |
let choosePhoto = UIAlertAction(title: "Photos Library", style: .default) { [unowned self] _ in | |
self.presentPhotoPicker(sourceType: .photoLibrary) | |
} | |
photoSourcePicker.addAction(takePhoto) | |
photoSourcePicker.addAction(choosePhoto) | |
photoSourcePicker.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) | |
present(photoSourcePicker, animated: true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment