I would like to be able to take a photo in view of my app. However, when I press the button, the screen becomes black. Could You please help me with that problem? I have the imageView and one button to make a photo.
I have such code:
var imagePicker: UIImagePickerController!
@IBOutlet var imageView: UIImageView!
@IBAction func takePhoto(_ sender: UIButton) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.camera
imagePicker.allowsEditing = false
let vc = ViewController()
var navigationController = UINavigationController(rootViewController: vc)
self.present(navigationController, animated: true, completion: nil)
}
All necessary delegates in class are added. Probably there is the mistake in self.present(), but in other cases it doesn't work.
self.presentViewController(imagePicker, animated: true, completion: nil) doesn't work in new version.
And second question: Is it able to see the camera screen directly in the view? Not only after pressing the button?