如何在联系人添加照片选项中实现编辑照片的移动比例照片选项

时间:2012-10-29 06:50:18

标签: iphone objective-c ipad uiimageview uiimagepickercontroller

在我的 iPhone应用中,添加了照片选项,我添加了照片from library as well as captured images ..

当我打开图像选择器添加/捕获图像时,它只显示重拍和放大使用照片。

当我点击使用时,它显示为图像视图中的图像

i need to display my selected crop, 就像在iphone的联系人应用中添加照片一样

我设置了 self.imagePickerController.allowsEditing = YES;

但是每当我想要编辑图像时,我都需要取回原始图像,而不是图像选择器中的缩放/裁剪图像再次编辑

1 个答案:

答案 0 :(得分:1)

你必须将UIImagePickerController的allowEditing设置为YES, 试试以下内容:

- (IBAction)takePicture:(id)sender {
UIImagePickerController *imagePicer = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    [imagePicer setSourceType:UIImagePickerControllerSourceTypeCamera];
} else {
    [imagePicer setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}

// This will sets the editing mode after taking of picking image from image picker

[imagePicer setAllowsEditing:YES];
[imagePicer setDelegate:self];

//place image picker on the screen
[self presentViewController:imagePicer animated:YES completion:nil];
}

如果您想使用编辑后的图像,请将“UIImagePickerControllerOriginalImage”更改为“UIImagePickerControllerEditedImage”,就是这样!!