【发布时间】:2017-01-18 15:20:36
【问题描述】:
我有一个 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)
}
但是,一旦我单击警报中的某个操作,什么都不会发生,它只是退出警报但不显示我的选择器
感谢任何帮助
【问题讨论】:
标签: swift3 uialertview