imagePickerController:didFinishPickingMediaWithInfo 问题

发布于 2024-10-19 22:48:42 字数 322 浏览 0 评论 0原文

如果我不编辑图片,结果会怎样?

(image = nil ? or image = OriginalImage) 

picker.allowsImageEditing = YES;

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
}

What is the result if I didn't edit the picture?

(image = nil ? or image = OriginalImage) 

picker.allowsImageEditing = YES;

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
}

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

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

发布评论

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

评论(1

ペ泪落弦音 2024-10-26 22:48:42

该键要么不存在于字典中,要么与原始图像相同。最简单的方法就是进行防御性编码:

UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
if (!image) image = [info objectForKey:UIImagePickerControllerOriginalImage];

这样,即使不同版本的 iOS 上的行为有所不同,您仍然可以获得合理的结果。

Either the key would not exist in the dictionary or it would be the same as the original image. The easiest thing to do is just to code defensively:

UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
if (!image) image = [info objectForKey:UIImagePickerControllerOriginalImage];

That way you'll still get sane results even if the behavior is different on different versions of iOS.

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