0
私はUIImagePickerControllerを使用していますが、画像を撮影するか、ライブラリから選択するかをユーザーに決定させたいと考えました。だから、これは警告でそれをやろうとしている私のコードです:アラートを使用してUIImagePickerControllerで画像ギャラリーまたはカメラを選択する
@IBAction func cameraButton(_ sender: UIButton) {
picker.allowsEditing = true
let alert = UIAlertController(title: "Choose one of the following:", message: "", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Gallery", style: .default, handler: { action in
self.picker.sourceType = .photoLibrary
}))
alert.addAction(UIAlertAction(title: "Camera", style: .default, handler: { action in
self.picker.sourceType = .camera
}))
self.present(alert, animated: true, completion: nil)
present(picker, animated: true, completion: nil)
}
しかし、私は、アラートのアクションのいずれかをクリックした後、何も起こらない、それだけで、アラートの外に出るが、
私のピッカーを提示していませんすべてのヘルプは