2 alllllllll alllllllll 于 2013.06.06 10:20 提问

iphone应用显示UIImage问题

ViewController中显示图片, ViewController.h:

UIImageView *image;
@property(nonatomic,retain) IBOutlet UIImage* image ;

ViewController.m

- (id)initWithImage:(UIImage *)image 
{
    UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameoffile.jpg"]];

    self.image = image;

    [image release];
}

但并没有让UIImage实例链接成功。

1个回答

zhanglei5415
zhanglei5415   Rxr 2013.06.06 10:23
已采纳

IBoutlet 更应该设置关联的是UIImageView.

@property(nonatomic,retain) IBOutlet UIImageView* imageView ;

- (id)initWithImage:(UIImage *)image 
{
    self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameoffile.jpg"]] autorelease];

}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!