iOS 8快照未渲染的视图会导致空快照 [英] iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot

查看:244
本文介绍了iOS 8快照未渲染的视图会导致空快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 8中我遇到从相机捕捉图像的问题,直到现在我使用此代码

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];

但是在iOS 8中我得到了这个:

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.

我尝试使用 This Post with

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];

...
controller.modalPresentationStyle=UIModalPresentationFullScreen;
or
controller.modalPresentationStyle=UIModalPresentationCurrentContext;
...

这个

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];
});

[self presentViewController:controller animated:YES completion:NULL];

[self presentViewController:controller animated:YES completion:^{

}];

任何想法?

推荐答案

我很确定这只是iOS 8.0中的一个错误。它可以与最简单的POC应用程序重现,它只是尝试提供一个 UIImagePickerController ,就像你上面所做的那样。此外,据我所知,没有其他模式可以显示图像选择器/相机。您甚至可以下载Apple的使用UIImagePickerController示例应用程序,运行它,它将生成相同的错误开箱即用。

I'm pretty sure this is just a bug in iOS 8.0. It's reproducible with the simplest of POC apps that does nothing more than attempt to present a UIImagePickerController like you're doing above. Furthermore, there's no alternative pattern to displaying the image picker/camera, to my knowledge. You can even download Apple's Using UIImagePickerController sample app, run it, and it will generate the same error out of the box.

这就是说,功能仍然适用于我。除了警告/错误之外,您的应用程序运行是否有问题?

That said, the functionality still works for me. Other than the warning/error, do you have issues with the functioning of your app?

这篇关于iOS 8快照未渲染的视图会导致空快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆