UIImagePickerController - 将图片裁剪成方形(纵向)

时间:2012-02-20 14:26:47

标签: ios xcode ios5 camera uiimagepickercontroller

我正在使用UIImagePickerController来拍摄和编辑图片。它在风景中工作得很好,但在肖像中它会将图片裁剪成正方形(不允许缩小图像以完全适合方形裁剪场,就像在风景中一样。任何想法?

代码:

-(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];
}

3 个答案:

答案 0 :(得分:11)

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

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

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

答案 1 :(得分:10)

我知道回答这个问题的时间已经很晚了,但有人可能觉得这很有用。

更改

[imagePicker setAllowsEditing:YES]; 

[imagePicker setAllowsEditing:NO];

谢谢, 杰

答案 2 :(得分:4)

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

This链接可能有助于此。