gpt4 book ai didi

ios - UIImagePickerController 错误 : Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7

转载 作者:IT王子 更新时间:2023-10-29 07:29:03 25 4
gpt4 key购买 nike

我只在 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 会弄乱 View ,而 iOS6 似乎可以正确管理它。

您应该在您的 UIViewController 中初始化您的相机,只有在 View 已加载且超时后:

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

关于ios - UIImagePickerController 错误 : Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18890003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com