如何更改 UIImagePickerController 裁剪框
当打开使用 UIImagePickerController 并设置 allowedImageEditing = YES 时; 默认裁剪框为 320x320。 就我而言,我想将横向图像的裁剪框设置为 320x240,将纵向图像设置为 240x320。 但是,我一直无法找到一种方法来更改编辑/裁剪照片时使用的 320x320 框架。 你们有人找到办法了吗?
谢谢!
when opening working with an UIImagePickerController and setting allowsImageEditing = YES; there is a default cropping frame that is 320x320. In my case, I would like to setup that cropping frame to 320x240 for images that are landscape, and 240x320 for images that are portrait. However, I haven't been able to find a way to change that 320x320 frame that is used when editing /cropping a photo. Has any of you found a way to do it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你必须自己实现它。
选取器仅执行 320x320 裁剪。
因此,请设置
allowedImageEditing = NO;
现在您将获得完整的图像。 然后,您将必须创建一个视图/视图控制器,它将裁剪为您想要的比例。
You have to implement it your self.
The picker only performs 320x320 cropping.
So instead set
allowsImageEditing = NO;
Now you will get the full image back. Then you will have to create a view/view controller that will crop to the proportions you desire.
您可以尝试 ShittyImageCrop。 它非常适合裁剪为特定的纵横比。 在您的情况下,将其显示为宽高比 4:3(或横向 3:4),如下所示:
之后,您可以使用其他一些代码将其缩放到所需的分辨率(320x240 或 240x320)。
You can try ShittyImageCrop. It's good for cropping to a specific aspect ratio. In your case, present it with aspect ratio 4:3 (or 3:4 in landscape) like this:
After that you can use some other code to just scale it to desired resolution (320x240 or 240x320).
这是最新的答案,其中包含必要的手动裁剪代码:手动裁剪
仍然无法逃避艰苦的工作。
This is the more recent answer with the necessary manual cropping code: Manual Crop
There is still no escaping the hard work.