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
UIImagePickerController - crops picture to square (in portrait)
提问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
谢谢,杰