从UIImagePickerController获取完整图像

时间:2015-01-31 19:36:50

标签: ios objective-c uiimagepickercontroller

我有一个UIImagePickerController,每次我选择一个图像,我得到图像的裁剪版本,我想要完整的图像,我该怎么做?

- (void)tapSelectAd:(id)sender
{

picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
picker.allowsEditing = YES;
picker.wantsFullScreenLayout = YES;


[self presentModalViewController:picker animated:YES];

 }




- (void)imagePickerController:(UIImagePickerController *) Picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
selectedImage.image = image;
}

1 个答案:

答案 0 :(得分:4)

试试这个:你需要将allowsEditing设置为NO,并在选择图像时使用UIImagePickerControllerOriginalImage。

- (void)tapSelectAd:(id)sender
{
    picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
    picker.allowsEditing = NO;
    picker.wantsFullScreenLayout = YES;

    [self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *) Picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
    selectedImage.image = image;
}