UIImagePicker 在 OS 3.1.2 中不显示照片库中的原始图像

发布于 2024-09-10 18:11:19 字数 809 浏览 0 评论 0原文

碉堡了!真的...我对这个问题感到沮丧,它让我在我的应用程序中陷入了一周。

这是代码

- (IBAction)loadTheImage {


 UIImagePickerController * picker = [[UIImagePickerController alloc] init];

 picker.delegate = self;

 picker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

 // picker.sourceType =  UIImagePickerControllerSourceTypeSavedPhotosAlbum;

 [self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

 [picker dismissModalViewControllerAnimated:YES];

 imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}

如果我将源设置为 SavedPhotosAlbum (相机胶卷),那么它可以正常工作。但是当我将它设置为 PhotoLibrary 时,它只是返回 nil。而这恰恰发生在OS3.1.2中。在 OS4 中它工作正常(即返回原始图像很好)。

有人吗?

Holy Crap! Really... I'm frustrated with this problem that get me stuck with my apps for a week now.

Here is the code

- (IBAction)loadTheImage {


 UIImagePickerController * picker = [[UIImagePickerController alloc] init];

 picker.delegate = self;

 picker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

 // picker.sourceType =  UIImagePickerControllerSourceTypeSavedPhotosAlbum;

 [self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

 [picker dismissModalViewControllerAnimated:YES];

 imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}

If I set the source as SavedPhotosAlbum (Camera Roll), then it works OK. But when I set it to PhotoLibrary, it just returns nil. And this just happens in OS3.1.2. In OS4 it works OK (ie returns the original image just fine).

Anybody?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-09-17 18:11:19

给定的源可能并不总是在每个设备上可用。这可能是因为源实际上不存在或因为当前无法访问。

在尝试使用 UIImagePickerController 对象选取图像之前,您必须调用 [UIImagePickerController isSourceTypeAvailable:] 方法以确保所需的源类型可用。

A given source may not always be available on every device. This could be because the source is not physically present or because it cannot currently be accessed.

Before attempting to use an UIImagePickerController object to pick an image, you must call [UIImagePickerController isSourceTypeAvailable:] method to ensure that the desired source type is available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文