JohnnyDark / IOS_MyLocation

0 stars 0 forks source link

选择使用相机或相册 #15

Open JohnnyDark opened 4 years ago

JohnnyDark commented 4 years ago
func pickPhoto() {
 if UIImagePickerController.isSourceTypeAvailable(.camera) {
 showPhotoMenu()
 } else {
 choosePhotoFromLibrary()
 }
}
func showPhotoMenu() {
 let alert = UIAlertController(title: nil, message: nil,
 preferredStyle: .actionSheet)
 let actCancel = UIAlertAction(title: "Cancel", style: .cancel,
 handler: nil)
 alert.addAction(actCancel)
 let actPhoto = UIAlertAction(title: "Take Photo",
 style: .default, handler: nil)
 alert.addAction(actPhoto)
 let actLibrary = UIAlertAction(title: "Choose From Library",
 style: .default, handler: nil)
 alert.addAction(actLibrary)
 present(alert, animated: true, completion: nil)
}