开发者

Set the image property of an UIImageView - Does not Work

Below is the relevant code

.h

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

.m

@synthesize productImageView

in the initWithNibName custom initialization:

NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"http://www.myurl.net/test.jpg"]];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
productImageView.image = ima开发者_高级运维ge;


  1. Don't forget the semicolon after the @synthesize directive.
  2. Have you connected the IBOutlet to your controller in Interface Builder?
  3. You have a memory leak: an UIImageView retains its image, so you need to release the one you allocate in your method.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜