iOS打开摄像头时出现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.
网上一堆办法都没有解决,求大神
代码
case 0://从照相机拍照
//--判断相机是否可用
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//有相机
UIImagePickerController *ipc = [[UIImagePickerController alloc]init];
ipc.modalPresentationStyle = UIModalPresentationCurrentContext;
//self.imagePicker = ipc;
[ipc setSourceType:UIImagePickerControllerSourceTypeCamera];
ipc.allowsEditing = YES;
ipc.delegate = self;
//self.imagePicker = ipc;
//跳转到UIImagePickerController
[self presentViewController:ipc animated:YES completion:nil];
}
else {
NSLog(@"这设备没相机 ");
}
break;
我也出现了这个提示,只不过不是调用相机,而是将程序切换到后台时,快晕了。
找答案时发现了一个相机的解决方法,我也没试过,作为参考。
http://blog.csdn.net/chenyong05314/article/details/44812085
我也碰到过这个问题,我最后发现原因是我的这个应用没有给照相机授权。你可以尝试下载设置中吧照相机授权给打开。
楼上那个方法我试过,还试过一些其他的方法,比如延时调用啦,把 imagePicker 存成全局变量啦,总之在爆栈上查到的方法我都试了一个遍了…… 结果都没有解决问题。
不过可以负责任地告诉题主~~ 这只是个 warning,不影响正常使用,某大公司的 app 也会报这个 warning。你就直接忽略掉它吧~
这个问题我也遇到过,当初也是寻找破解之法来着,奈何天不遂人愿,终不得其解啊。然观其不影响正常使用,故搁置一旁了。