关于 ios:UIImagePickerController – 将图片裁剪为正方形(纵向)

UIImagePickerController - crops picture to square (in portrait)

我正在使用 UIImagePickerController 来拍摄和编辑图片。它在横向工作正常,但在纵向它将图片裁剪成正方形(不允许像横向一样缩小图像以完全适合方形裁剪字段。有什么想法吗?

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
-(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];
}

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

1
2
3
4
5
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;

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


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

改变

1
[imagePicker setAllowsEditing:YES];

1
[imagePicker setAllowsEditing:NO];

谢谢,
周杰伦


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

此链接可能对此有所帮助。