在我的应用中,用户可以使用下面的代码从库中选择照片。因为我希望用户裁剪照片,所以我确保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"];
答案 0 :(得分:2)
您只需使用“UIImagePickerControllerEditedImage”而不是“UIImagePickerControllerOriginalImage”。
感谢。