在我的应用程序中,用户可以使用以下代码从图库中选择照片。因为我希望用户裁剪照片,所以我确保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"];
最佳答案
您只需要使用“ UIImagePickerControllerEditedImage”而不是“ UIImagePickerControllerOriginalImage”即可。
谢谢。