http://www.4byte.cn/question/474924/uiimagepickercontroller-error-snapshotting-a-view-that-has-not-been-rendered-results-in-an-empty-snapshot-in-ios-7.html
我只是在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。
任何人都有线索吗?谢谢你在前进。
在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];
}
也许这不是一个解决你的问题却依然。
presentModalViewController:animated:
在iOS 6不赞成。以目前的一个模态视图,使用
presentViewController:animated:completion:
而不是。你可以通过
nil
为完成处理程序,如果你没有什么后做
viewDidAppear:
的方法被提出的视图控制器。
也许这不是一个解决你的问题却依然。presentModalViewController:animated:
在iOS 6不赞成。以目前的一个模态视图,使用presentViewController:animated:completion:
而不是。你可以通过nil
为完成处理程序,如果你没有什么后做viewDidAppear:
的方法被提出的视图控制器。
试试这个,使用
[self performSelector:@selector(presentCameraView) withObject:nil afterDelay:1.0f];
和功能
-(void)presentCameraView{
[self presentViewController:imagePicker animated:YES completion:nil];
}
代替。[self presentModalViewController:imagePicker animated:YES];
和事业作出imagePicker
作为一个全局变量。
我在建筑应用的iOS SDK 6.1得到这个错误,部署目标iOS 6.1和iOS 7供电的iPhone上运行的应用程序。应用程序不会崩溃,但实现UIViewController shouldAutorotate
的方法帮助我去除错误消息。
- (BOOL)shouldAutorotate {
return YES;
}
这是什么固定为我的应用程序,你的方法可能是不同的
首先,它是一个iPhone,ipad应用
在appname-info.plist。在支持界面取向(ipad)显示4个方向。
在支持的接口方向显示的3个方向。我加了第四把应用程序,没有调试输出。
希望这会有所帮助。
我有问题时,我试图把相机视图内的一个松饼。在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
被称为。
这个错误也出现在我的苹果photopicker示例代码项目。
我是用Xcode 5版和iOS 7.0.3在iPhone 4。
重现步骤:
-
下载苹果的photopicker样本项目https://developer.apple.com/library/ios/samplecode/photopicker/introduction/intro.html
-
在aplviewcontroller M注释掉线125。
/ / imagepickercontroller.showscameracontrols =不;
-
在aplviewcontroller。M注释掉线130-133.
/ / [ [ nsbundle mainbundle ] loadnibnamed:”“overlayview”业主:自我选择:零];
/ / self.overlayview.frame = imagepickercontroller.cameraoverlayview.frame;
/ / imagepickercontroller.cameraoverlayview = self.overlayview;
/ / self.overlayview = nil;
-
建立和启动应用程序。
-
一旦启动,旋转到景观模式的装置。
-
点击相机图标在相机模式打开uiimagepickercontroller。
-
查看控制台输出。
控制台输出
photopicker [ 240:60b ]照片一看,不是在一个空的快照被渲染的结果。确保你的观点已经呈现之前至少有一次快照或快照后,屏幕更新。
showscameracontrols财产
问题发生时给我这个有价值的是(默认)。
设置这个没有消除消息。
错误报告
我只是向苹果的错误报告。
我试过许多已经在不同的岗位,提出的建议,但没有找到一个满意的解决方法。
我也有同样的问题时,我试图修改来与应用程序的演示avirary SDK,在演示应用程序,它只能编辑挑选从相机的照片。试图通过捕获从相机编辑照片,我第一次添加以下代码中的M文件的处理:
#pragma mark - Take Picture from Camera
- (void)showCamera
{
//[self launchPhotoEditorWithImage:sampleImage highResolutionImage:nil];
if ([self hasValidAPIKey]) {
UIImagePickerController * imagePicker = [UIImagePickerController new];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
[imagePicker setAllowsEditing:YES]; //important, must have
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:imagePicker animated:YES completion:nil];
}else{
[self presentViewControllerInPopover:imagePicker];
}
}
}
当我运行的应用程序,错误发生:
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.
为了解决错误,修改uiimagepicker代表你的uiviewcontooler M文件,如下所示:
#pragma mark - UIImagePicker Delegate
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL * assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
void(^completion)(void) = ^(void){
[[self assetLibrary] assetForURL:assetURL resultBlock:^(ALAsset *asset) {
if (asset){
[self launchEditorWithAsset:asset];
}
} failureBlock:^(NSError *error) {
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"Please enable access to your device's photos." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
UIImage * editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
if(editedImage){
[self launchPhotoEditorWithImage:editedImage highResolutionImage:editedImage];
}
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self dismissViewControllerAnimated:YES completion:completion];
}else{
[self dismissPopoverWithCompletion:completion];
}
}
那么错误消失,应用工程!