我有一个按钮,当我录音按钮相机,并采取pictures.after拍照,我需要显示警报到user.the警报部分不工作。在这里输入图像描述
发布于 2018-03-19 12:37:45
这段代码适用于我,我能够解决我的问题。
func cameraAsscessRequest() {
if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) == AVAuthorizationStatus.authorized {
} else {
AVCaptureDevice.requestAccess(for: AVMediaType.video) { granted -> Void in
}
}
}
func image(){
if !UIImagePickerController.isSourceTypeAvailable(.camera){
let alertController = UIAlertController.init(title: nil, message: "Device has no camera.", preferredStyle: .alert)
let okAction = UIAlertAction.init(title: "Alright", style: .default, handler: {(alert: UIAlertAction!) in
})
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
else{
//other action
imagePicker.sourceType = .camera
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.camera
imagePicker.allowsEditing = false
self.present(imagePicker,animated: true,completion: nil)
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let pickedimage = info[UIImagePickerControllerOriginalImage] as?UIImage{
let alert = UIAlertController(title: "",
message: "Are you sure you want to upload invoice ?",
preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) {
UIAlertAction in
Print("Camera On")
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) {
UIAlertAction in
print("lll")
}
alert.addAction(cancelAction)
alert.addAction(okAction)
self.dismiss(animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
}
}发布于 2018-03-13 07:23:46
为此,您需要对AlertController的当前方法进行调整,然后显示您自己的方法,将用户输入转发到原始警报。反正我也不喜欢这个。
发布于 2018-03-13 07:25:10
在添加操作后添加这一行:
self.present(alert, animated: true, completion: nil)https://stackoverflow.com/questions/49250402
复制相似问题