UIImagePickerController中的自定义裁剪尺寸 [英] Custom Crop Size in UIImagePickerController
问题描述
我一直在努力解决这个问题,因为关于这个问题的文档很少。我在我的iPhone应用程序中有一个 UIImagePickerController
,用于选择要在以后作为视图背景应用的图像。这很容易做到。不幸的是,如果用户从相机胶卷中选择一个大图像,则需要调整大小并进行裁剪才能看起来不错。
I've been struggling with this for awhile now, since there is little documentation on the subject. I have a UIImagePickerController
in my iPhone application that I use to select an image to be applied as the background of a view later. This is easy enough to do. Unfortunately, if a user selects a large image from their camera roll it needs to be resized and cropped in order to look decent.
切换<$ c $很容易c> picker.allowsEditing 到 YES
并获取图像编辑器,但默认裁剪尺寸太小。我需要将它设置为iPhone屏幕的全尺寸(旧型号为320,新型号为640)。你是怎样做的?我一直在谷歌搜索并查看Apple的文档,但我找不到任何东西。我发现的最好的解决方案是2009年的一个有点错误的解决方案( http:// blog.stormyprods.com/2009/06/image-picker-sample.html )几乎有效,但它将图像向下移动约20px。 (另外,它有点过于复杂。)当然有一个优雅,简单的解决方案,我缺少?
It's easy enough to toggle picker.allowsEditing
to YES
and get the image editor up, but the default crop dimensions are too small. I need to set it to the full dimensions of the iPhone screen (320 for the old models, 640 for the new). How do you do that? I've been Googling and looking at Apple's documentation, but I can't find anything. The best I found is a slightly buggy solution from 2009 (http://blog.stormyprods.com/2009/06/image-picker-sample.html) that almost works, but it shifts the image down about 20px. (Plus, it's a bit over-complicated.) Surely there's an elegant, simple solution that I'm missing?
推荐答案
一个一年后 - 像你一样,我没有找到任何有用的东西,所以我创建了这个项目
- 一个自定义大小裁剪和缩放编辑UIImagePicker Popover for iPad。
One year later - Hi, like you, i haven't found anything useful, so i created this Project - a custom size crop and zoom editing UIImagePicker Popover for the iPad.
你可以轻松地为iPhone改变它,希望能帮助别人。
这是 - https://github.com/yogev77/UIImagePickerWithEditor
You could easily change it for the iphone, hope that helps someone. Here it is - https://github.com/yogev77/UIImagePickerWithEditor
这篇关于UIImagePickerController中的自定义裁剪尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!