Iphone:在imageview上看不到图像

时间:2012-10-12 12:50:52

标签: iphone image imageview

我正在尝试将图像设置为imageview但它无法正常工作,我将所有连接设置为Interface Builder。

运行程序时,调试器显示以下内容:

(lldb) po image
(UIImage *) $2 = 0x06ed2290 <UIImage: 0x6ed2290>

对于imageview,它说:

(lldb) po self.imageView
(UIImageView *) $1 = 0x06eac5e0 <UIImageView: 0x6eac5e0; frame = (0 0; 0 0); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6ead050>>

使用以下代码设置图像:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    [self.imageView setImage:image];
    [popoverController dismissPopoverAnimated:YES];
    [picker dismissModalViewControllerAnimated:YES];
     }

但图像没有显示。

1 个答案:

答案 0 :(得分:0)

[picker dismissModalViewControllerAnimated:YES];
imageView = [[UIImageView alloc]initWithFrame:CGRectMake(80, 80, 150, 150)];
[imageView setUserInteractionEnabled:YES];
imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];

用这个修改你的代码也许会有所帮助:)... 你还没有添加Image frame吗?