My var:
@IBOutlet weak var imageView: UIImageView!
Take photo function:
func takePhoto(){
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .Camera
presentViewController(picker, animated: true, completion: nil)
}
Error message:
Snapshotting a view that has not been rendered results in an empty
snapshot. Ensure your view has been rendered at least once before
snapshotting or snapshot after screen updates
Any ideas?
I have had the same problem - I have two options once I have called the VC - From Photos or Selfie - and when I select Selfie i.e. camera Xcode prints that message but not ion I select Photos - so my guess is its a bug in the camera app.
It has never crashed my app so I ignore it Code:
@IBAction func openCameraButton(sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) == true {
camera = true
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
self.presentViewController(imagePicker, animated: true, completion: nil)
}else{
noCamera()
}
}
Make sure you have:
super.viewDidLoad()
in your viewDidLoad func.
put your self.presentViewController
or your self.navigationController?.showViewController
inside dispatch_async(dispatch_get_main_queue()) {
dispatch_async(dispatch_get_main_queue()) {
self.presentViewController(imagePicker, animated: true, completion: nil)
}
Your code looks fine. I would restart XCode and double check your didFinishPickingImage method to make sure it's closing properly. The issue could be with your transitions. This has happened to me several times in the past and never became a big deal.
You are probably assigning it to another UIImageView too fast, try to save it in another variable first and in the func ViewDidLoad put that image into the UIImageView. That worked for me!
goto setting -> privacy -> camera and enable or disable camera access for individual apps
This issue seems to occur when the key: "CFBundleDisplayName" has an empty string value in the Info.plist.