NSString *urlString = @"http://img4.bitauto.com/autoalbum/files/20100226/003/201002260944098032_1155951_4.jpg";
NSURL *url = [NSURL URLWithString:urlString];
NSData *myData = [NSData dataWithContentsOfURL: url];
UIImage *myImage = [UIImage imageWithData: myData];
UIImageView *myImageView = [[UIImageView alloc] initWithImage: myImage];
UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];
myScrollView.contentSize = CGSizeMake(myImage.size.width, myImage.size.height;
[self.view addSubview: myScrollView];
[myScrollView release];
[myScrollView addSubview: myImageView];
[myImageView release];
如果返回url是nil,则用下面的代码代替:
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];