uiimagePickerController(照片库/相机)选择的图像未显示

时间:2011-05-09 20:17:37

标签: iphone objective-c xcode uiimageview

我的页面中有一个UIImageView插座。我想要用一个用户选择的图像填充。因此,点击下面的按钮,用户可以从库/相机中选择图像。 直到这里一切都很好。但是,一旦用户从照片库中选择图像,它就不会在UIIMageView上显示它。以下是代码

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[picker dismissModalViewControllerAnimated:YES];
imageView1.image = [info objectForKey:@"UIImagePickerControllerEditImage"];
NSLog(@"Image being added to the view");

}

NSLog in console确认函数调用。有关为什么没有显示图像的任何评论?

3 个答案:

答案 0 :(得分:0)

您的方法应如下所示:

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

{

[picker dismissModalViewControllerAnimated:YES];

imageView1.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}

答案 1 :(得分:0)

字典信息由{

组成
UIImagePickerControllerMediaType = "public.image";
UIImagePickerControllerOriginalImage = "<UIImage: 0x7c73290>";
UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=70252FFF-1654-49A5-9FEE-5FF19454AE3F&ext=JPG";

}

通过这个,您可以使用密钥拍摄图像;

答案 2 :(得分:0)

我认为你没有给出口连接。 如果你给了连接, 实现此Delegate方法。在方法体中使用输入参数“image”,如:

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

{

     myImageView.image = image;

}

多数人。