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;
- Don't forget the semicolon after the
@synthesize
directive. - Have you connected the
IBOutlet
to your controller in Interface Builder? - You have a memory leak: an
UIImageView
retains its image, so you need torelease
the one you allocate in your method.
精彩评论