2013-04-29 72 views
0

正如标题所暗示的,如果我设置选取器没有返回任何图像,如果allowsEditing = NO

imagePickerController.allowsEditing = YES;

imagePickerController.allowsEditing = NO

我没有得到任何图像回来了?我已搜查SO,并不能找到一个明确的答案

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = NO; 
    [self.editController presentModalViewController:imagePicker animated:YES]; 


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    DebugLog(@"info dict: %@", info); 
    [picker dismissModalViewControllerAnimated:YES]; 
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; 
    self.schemeLogo.backgroundColor = [UIColor whiteColor]; 
    self.schemeLogo.image = image; 
    NSData *imageData1 = UIImagePNGRepresentation(image); 
    NSString *path1 = [ICUtils pathForDocument:@"schemeLogo.png"]; 
    [imageData1 writeToFile:path1 atomically:NO]; 
} 
+1

你会得到即使allowsEditing设置为NO的图像。你的(void)imagePickerController在哪里:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info? – 2013-04-29 11:33:42

+0

啊,修好了!感谢您指向我 - (无效)imagePickerController:(UIImagePickerController *)选择器didFinishPickingMediaWithInfo:(NSDictionary *)信息{ – JSA986 2013-04-29 11:47:48

回答

5

固定,需要

[info objectForKey:UIImagePickerControllerOriginalImage];

+0

如果你这样做,那么你会得到原始图像未编辑的图像。那么设置'allowEditing = YES'有什么好处? – TheTiger 2013-12-26 05:31:29

+0

这个问题指出原始图像是需要的。这样做的目的是返回原始图像。当需要ediitiong时使用'allowsEditing = YES'。在这种情况下不是。 – JSA986 2013-12-28 11:36:12