2013-03-30 45 views
0

在我的應用程序中,用戶可以使用下面的代碼從庫中選擇一張照片。因爲我希望用戶裁剪照片,所以我確保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

回答

2

你只需要使用 「UIImagePickerControllerEditedImage」 而不是 「UIImagePickerControllerOriginalImage」。

謝謝。

+0

是的,工作! - 非常感謝你 – pete