2011年3月8日 星期二

[iOS Dev] Load Image From URL


NSString *urlString = [NSString stringWithString:@"http://teddymaulana.files.wordpress.com/2009/11/iu1.jpg"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
CGRect frame = CGRectMake(75, 75, 160, 230);
[imgView setFrame:frame];
[imgView setContentMode: UIViewContentModeScaleAspectFit];
[self.view addSubview:imgView];
[imgView release];
Related Posts Plugin for WordPress, Blogger...