Swift Bug: Snapshotting a view that has not been rendered results in an empty snapshot

1.4k Views Asked by At

I have read many postings on this website (especially this: iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot) but there is no answer for Swift.

Thought I would ask the crowd here if they have solved this problem or not.

I am using Xcode 6.2, iOS 8.2 on an iPhone 6

My code:

if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
        if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
            imag = UIImagePickerController()
            imag.delegate = self
            imag.sourceType = UIImagePickerControllerSourceType.Camera;
            imag.allowsEditing = false
            imag.mediaTypes = [kUTTypeImage]
            imag.showsCameraControls = false
            self.presentViewController(imag, animated: true, completion: nil)
            imag.cameraDevice = UIImagePickerControllerCameraDevice.Front
            imag.takePicture()
        }
    }

If I change this (self.presentViewController(imag, animated: true, completion: nil)) to (self.presentViewController(imag, animated: YES, completion: nil)), I get and error to switch back to true.

1

There are 1 best solutions below

0
On

I'm getting the same warning in console , but everything else should work. if the camera is not shown up , check camera permission in device setting.