In iOS 8 I am having problem capturing images from camera till now I am using this code for
UIImagePickerController *controller=[[UIImagePickerController alloc] init];
controller.videoQuality=UIImagePickerControllerQualityTypeMedium;
controller.delegate=(id)self;
controller.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentViewController:controller animated:YES completion:nil];
But in iOS 8 I am getting this:
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.
I have tried with the solution provided by This Post with
@property (strong,nonatomic)UIImagePickerController *controller;
_controller=[[UIImagePickerController alloc] init];
_controller.videoQuality=UIImagePickerControllerQualityTypeMedium;
_controller.delegate=(id)self;
_controller.sourceType=UIImagePickerControllerSourceTypeCamera;
_[self presentViewController:controller animated:YES completion:nil];
and this
...
controller.modalPresentationStyle=UIModalPresentationFullScreen;
or
controller.modalPresentationStyle=UIModalPresentationCurrentContext;
...
and this
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self presentViewController:controller animated:YES completion:nil];
});
and this
[self presentViewController:controller animated:YES completion:NULL];
and this
[self presentViewController:controller animated:YES completion:^{
}];
any idea?
I also encounter the same problem and I resolved it by checking if the camera is available:
I got the same bug,getting bellow message in console while opening camera.
'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.'
For me problem was with the Bundle display name in Info.plist file.it was empty some how,i put my app name there and now it working fine.i did't received any camera permission alert because of empty Bundle display name.it blocked the view from rendering.
the problem was't with view but by presenting it without a permission.you can check it on settings-->privacy-->Camera,if your app not listed there problem might be same.
Alternatively, consider using
drawViewHierarchyInRect
:Swift:
Objective-C:
Also see:
You can silence the "Snapshotting a view" warning by referencing the
view
property before presenting the view controller. Doing so causes the view to load and allows iOS render it before taking the snapshot.I was struggling with this issue for several hours, i have read every relevant topic and found out that the error was caused because under the privacy settings of my device, the camera access to my app was blocked!!! I have never denied access to camera and i don't know how it was blocked but that was the problem!
This might be a bug of built-in ImagePickerController. My code is working, but occasionally crashes on iPhone 6 Plus.
I've tried all solutions suggested by other answers but there were no luck. Problem finally solved after switching to JPSImagePickerController.