Hi Claude, I tried something to see the execution sequence. Please find as follows:-
@IBAction func takeClientIdCardFrontPic() {
DispatchQueue.main.async {
let picker = UIImagePickerController()
picker.sourceType = .camera
picker.delegate = self
print("process 1")
self.present(picker, animated: true, completion: { self.clientIdCardFrontImage.image = self.imageTaken })
print("process 2")
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true, completion: nil)
guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { return }
imageTaken = image
print("process 3")
}
The printed results were :-
process 1
process 2
process 3
while they should be :-
process 1
process 3
process 2
if they were going in sequence, despite that I used the DispatchQueue.main.async. I think if we figure out why its not waiting for me to take the picture the issue will be resolved