开发者

Set the image property of an UIImageView - Does not Work

开发者 https://www.devze.com 2023-01-12 17:09 出处:网络
Below is the relevant code .h IBOutlet UIImageView *productImageView; @property(nonatomic, retain) IBOutlet UIImageView *productImageView;

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

精彩评论

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