【发布时间】:2014-09-17 07:31:48
【问题描述】:
在 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:^{
}];
有什么想法吗?
【问题讨论】:
-
有同样的问题,而且这个错误会导致我的应用程序多次崩溃。希望更新 8.0.2 将修复此错误。当我在 iOS7 中运行我的应用程序时,它就像魅力一样工作,没有任何愚蠢的警告。看起来 iOS 8 的稳定性还有很长的路要走。
-
事件与 8.0.2 更新此问题仍然存在
-
我遇到了同样的问题。拍完照片后,我正在另一个线程中进行一些处理。将代码移至主线程后,一切正常。即,我之前的代码是:
dispatch_async(dispatch_get_main_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{,我改成dispatch_async(dispatch_get_main_queue(), ^{ -
iOS 8.1 出现同样的问题
-
在 iOS 9 中也会发生。
标签: objective-c ios8 uiimagepickercontroller