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 吗?

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

4

2 回答 2

0
-(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];

}

我真的很抱歉打扰,真的很感激你给的时间.. :-)

于 2011-04-07T17:34:29.530 回答
0

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

于 2011-04-07T16:01:27.447 回答