9

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?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Eri-Sklii
  • 549
  • 4
  • 10
  • 21

6 Answers6

2

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()

    }
}
Jeremy
  • 145
  • 1
  • 2
  • 13
  • I don't get it, could you explain more while giving feedback on the OP please ? – Gar Aug 12 '16 at 17:03
  • I segue to a VC which has an Image view and a toolbar with 2 options one to get a photo from a library and the other to use the camera. The only time I get the warning when I select the camera and the camera app has loaded: – Jeremy Aug 13 '16 at 06:59
1

Make sure you have:

super.viewDidLoad()

in your viewDidLoad func.

FlatDog
  • 2,685
  • 2
  • 16
  • 19
1

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)
}   
Dey
  • 842
  • 9
  • 21
0

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.

0

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!

Cano
  • 13
  • 5
0

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.

shan
  • 136
  • 7