我只在iOS 7中得到这个错误,应用程序崩溃了。在iOS 6中,我从未收到任何错误,打开相机时只收到一次内存警告。
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.这就是我在做的事情。
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setAllowsEditing:YES];
[self presentModalViewController:imagePicker animated:YES];我确实试图延迟presentModalViewController,但我仍然收到同样的消息。几秒钟后(7-10秒),应用程序崩溃。
此错误仅存在于iOS 7中。
有人知道线索吗?
发布于 2013-10-14 10:04:10
iOS7中的问题与转换有关。看起来,如果之前的转换没有完成,并且启动了一个新的转换,iOS7就会破坏视图,而iOS6似乎会正确地管理它。
您应该在UIViewController中初始化相机,只有在视图加载并具有超时之后:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//show camera...
if (!hasLoadedCamera)
[self performSelector:@selector(showcamera) withObject:nil afterDelay:0.3];
}这是初始化代码
- (void)showcamera {
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setAllowsEditing:YES];
[self presentModalViewController:imagePicker animated:YES];
}发布于 2013-11-02 15:05:48
这个错误也出现在苹果的PhotoPicker示例代码项目中。
我在iOS 4上使用了Xcode版本5.0和iPhone 7.0.3。
复制步骤:
//imagePickerController.showsCameraControls = NO;//[[NSBundle mainBundle] loadNibNamed:@"OverlayView" owner:self options:nil];
// self.overlayView.frame = imagePickerController.cameraOverlayView.frame;
// imagePickerController.cameraOverlayView = self.overlayView;
// self.overlayView = nil;控制台输出
PhotoPicker240:60b对未呈现视图的快照进行快照,结果为空快照。确保在快照或屏幕更新后的快照之前至少呈现过一次视图。
showsCameraControls property
当这个值为YES (默认值)时,就会出现问题。
将此设置为“否”可消除此消息。
Bug报告
我刚向苹果提交了一份窃听器报告。
我尝试过在不同岗位上提出的许多建议,但没有找到令人满意的解决办法。
发布于 2013-10-23 17:53:31
当我试图在弹出框内呈现相机视图时,我遇到了这个问题。在iOS6下,这没什么问题,但在iOS7中,我得到了消息
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.也是。
然而,在我将相机视图的显示方式更改为全屏(如拍摄图片和电影,iOS开发者库中所描述的)之后,一切又变得很好,并且消息再也没有出现。然而,我必须确保,根据应用程序的模式(例如,呈现相机视图或照片卷),无论何时调用- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker方法,我都必须关闭弹出窗口或视图控制器。
https://stackoverflow.com/questions/18890003
复制相似问题