ios UIImagePickerController - 将图片裁剪为正方形(纵向)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9362712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:55:03  来源:igfitidea点击:

UIImagePickerController - crops picture to square (in portrait)

iosxcodeios5camerauiimagepickercontroller

提问by cabhara

I'm using the UIImagePickerController to take and edit a picture. it works fine in landscape, but in portrait it will crop the picture into a square (does not allow to reduce the image to fit fully into the square crop field like in landscape. Any ideas?

我正在使用 UIImagePickerController 拍摄和编辑图片。它在风景中工作正常,但在人像中它会将图片裁剪成正方形(不允许缩小图像以完全适合风景中的方形裁剪场。有什么想法吗?

code:

代码:

-(IBAction)initCamera:(id)sender{

//Init imagePicker instance
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];

[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setShowsCameraControls:YES];
[imagePicker setAllowsEditing:YES];

[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}

回答by Andrey Zverev

Check out GKImagePickerlibrary, it allows to set your custom image crop area, like this:

查看GKImagePicker库,它允许设置您的自定义图像裁剪区域,如下所示:

self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;

[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];

回答by Jay Pandya

I know its really late to answer this question, But someone may find this helpful.

我知道回答这个问题真的很晚,但有人可能会觉得这很有帮助。

Change

改变

[imagePicker setAllowsEditing:YES]; 

To

[imagePicker setAllowsEditing:NO];

Thanks, Jay

谢谢,杰

回答by Peter Sarnowski

You can provide a custom cropping UI, but there is no way to change just the cropping rectangle of the standard one.

您可以提供自定义裁剪 UI,但无法仅更改标准裁剪矩形。

Thislink might help with that.

链接可能会有助于利用。