如何在 UIImageView、iPad 中查看从照片库弹出窗口中选择的图像
我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先在 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.
我真的很抱歉打扰,并且非常感谢您抽出宝贵的时间..:-)
I am really sorry for bothering, and really appreciating your given time.. :-)