如何在 UIImageView、iPad 中查看从照片库弹出窗口中选择的图像

发布于 2024-10-30 22:53:35 字数 742 浏览 7 评论 0原文

我正在为 iPad 开发一个应用程序,它工作正常,直到我到达这一点:

该应用程序显示照片库的弹出窗口,但是当我选择照片时,弹出窗口不会隐藏,我也希望它能够查看UIImageView 中选定的图像,但我不知道如何。

我确信 didFinishpickingMediaWithInfo 函数有问题。 这是该函数的代码:

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

    //bgImage is a UIImageView
bgImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

// Dismiss UIImagePickerController and release it
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];
[picker release];}

我的第一个问题是:我应该向该函数添加什么才能在 UIImageView 中查看所选照片?

2-我读到我应该使用 UIImage 而不是 UIImageView ..这是真的吗?如果是的话,界面构建器怎么样?没有什么叫 UIImage 吗?

非常感谢提前..:-) 问候,拉万

I am working on an application for iPad, it is working fine until i reached this point:

The app shows the popover for the photo library, but when I choose the photo, the popover doesn't hide, and I also want it to view the selected image in a UIImageView, however i do not knowhow.

I am sure there is something wrong in the didFinishpickingMediaWithInfo function.
here is the function's code:

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

    //bgImage is a UIImageView
bgImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

// Dismiss UIImagePickerController and release it
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];
[picker release];}

My first question is: What am i supposed to add to this function for viewing the selected photo in the UIImageView?

2- I have read that I should've used UIImage instead of UIImageView.. Is this true? If yes, what about the interface builder? there is nothing called UIImage ?

Many thanks in advance.. :-)
Regards, Rawan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上得阳光 2024-11-06 22:53:35

首先在 IB 中添加一个 UIImageView,在 .h 文件中为该 UIImageView 创建 IBOutlet,然后将 UIImageView 连接到 IB 中的此 IBOutlet。然后在 didFinishpickingMediaWithInfo 中获取 UIImage 实例中的 selectedImage,然后调用 setImage 到您为 UIImageView 创建的 IBOutlet 并将所选图像实例传递给 setImage。

First add an UIImageView in IB the create IBOutlet for that UIImageView in your .h file then connect UIImageView to this IBOutlet in IB. Then in your didFinishpickingMediaWithInfo get the selectedImage in an UIImage instance and then call setImage to that IBOutlet you created for UIImageView and pass the selected image instance to setImage.

高跟鞋的旋律 2024-11-06 22:53:35
-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{
    // TempImage is a UIImage instance
    TempImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    //bgImage is a UIImageView instance and it's connected in the IB
    [bgImage setImage:TempImg];
    // Dismiss UIImagePickerController and release it
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];

}

我真的很抱歉打扰,并且非常感谢您抽出宝贵的时间..:-)

-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{
    // TempImage is a UIImage instance
    TempImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    //bgImage is a UIImageView instance and it's connected in the IB
    [bgImage setImage:TempImg];
    // Dismiss UIImagePickerController and release it
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];

}

I am really sorry for bothering, and really appreciating your given time.. :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文