objective-c - iOS 8 对尚未渲染的 View 进行快照会导致快照为空

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

UIImagePickerController *controller=[[UIImagePickerController alloc] init];
controller.videoQuality=UIImagePickerControllerQualityTypeMedium;
controller.delegate=(id)self;
controller.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentViewController:controller animated:YES completion:nil];

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

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 提供的解决方案与

@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 就像你在上面做的那样。此外,据我所知,没有其他模式可以显示图像选择器/相机。你甚至可以下载苹果的Using UIImagePickerController sample app ,运行它,它会立即生成相同的错误。

也就是说,该功能仍然适用于我。除了警告/错误之外,您的应用的功能是否存在问题?

https://stackoverflow.com/questions/25884801/

相关文章:

iphone - 如何在我的 iPhone 应用程序中使用 NSError?

ios - 从 "bouncing"垂直停止 UIWebView?

ios - 在一个 UITableViewCell 上隐藏分隔线

objective-c - 了解 dispatch_async

ios - 将 NSString 转换为 NSDate(然后再返回)

objective-c - 开始使用 instancetype 而不是 id 会有好处吗?

objective-c - 实现 API 时如何避免在 block 中捕获 self ?

ios - 如何在 iOS 上进行 base64 编码?

ios - 卸载应用程序时删除钥匙串(keychain)项目

ios - 使 UINavigationBar 透明