UIImagePickerController - crops picture to square (in portrait)

て烟熏妆下的殇ゞ 提交于 2019-12-03 11:30:42

问题


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?

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

回答1:


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

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

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



回答2:


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




回答3:


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

This link might help with that.



来源:https://stackoverflow.com/questions/9362712/uiimagepickercontroller-crops-picture-to-square-in-portrait

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!