图书馆的照片不会移动和缩放

时间:2013-03-30 22:46:14

标签: iphone ios

在我的应用中,用户可以使用下面的代码从库中选择照片。因为我希望用户裁剪照片,所以我确保setAllowsEditing:YES。

当您选择照片时,您可以移动并缩放图像,但稍后查看图像时(selectedImage)图像将恢复为原始尺寸???

    myPicker = [[UIImagePickerController alloc] init];
    [myPicker setSourceType: UIImagePickerControllerSourceTypePhotoLibrary];
    [myPicker setToolbarHidden:NO];
    [myPicker setAllowsEditing:YES];
     myPicker.delegate = self;

    //this adds mypicker to current view
    [self presentViewController:myPicker animated:YES completion:NULL];


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
selectedImage = [[UIImage alloc]init];

selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

enter image description here

1 个答案:

答案 0 :(得分:2)

您只需使用“UIImagePickerControllerEditedImage”而不是“UIImagePickerControllerOriginalImage”。

感谢。