来自UIImagePicker的Iphone图像没有显示

时间:2010-12-28 20:55:16

标签: iphone ios uiimagepickercontroller

我有一个TabBarController,其中一个选项卡有一个ImageView。此外,我有一个按钮来显示ImagePicker和以下代码:

- (void) imagePickerController:(UIImagePickerController *)picker 
                             didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [self dismissModalViewControllerAnimated:YES];
    [picker release];
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    imageView.image = image;
}

但调用此方法时,ImageView中的图像不会显示。

有什么想法吗?

由于

(我在单独的视图中尝试过它,但是我不知道发生了什么)

1 个答案:

答案 0 :(得分:2)

首先,你首先要解雇你的选择器,你可以尝试:

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
[self dismissModalViewControllerAnimated:YES];

或者你可以试试这个代表:

-(void)imagePickerController:(UIImagePickerController *)picker 
       didFinishPickingImage:(UIImage *)image 
                 editingInfo:(NSDictionary *)editingInfo {

    NSData *chosenImage = UIImageJPEGRepresentation(image, 1.0);

    yourImage.image = [UIImage imageWithData:chosenImage];

}