库中的照片不会移动和缩放

Posted

技术标签:

【中文标题】库中的照片不会移动和缩放【英文标题】:photo from library will not move and scale 【发布时间】:2013-03-30 22:46:13 【问题描述】:

在我的应用中,用户可以使用以下代码从库中选择一张照片。因为我希望用户裁剪照片,所以我确保 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"];

【问题讨论】:

【参考方案1】:

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

谢谢。

【讨论】:

以上是关于库中的照片不会移动和缩放的主要内容,如果未能解决你的问题,请参考以下文章