-2
請指導我爲iphone編寫代碼,我想要顯示瀏覽圖像的路徑以及顯示該圖像?iphone開發
請指導我爲iphone編寫代碼,我想要顯示瀏覽圖像的路徑以及顯示該圖像?iphone開發
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.kitco.com/images/live/silverw.gif"]];
if([imageData length] == 0){
/*NSString *imagePath = [[NSString alloc] initWithFormat:@"%@/%@",[[NSBundle mainBundle] resourcePath],@"no_image.png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
[item setObject:image forKey:@"itemImage"];
[imagePath release];
[image release];*/
}
else {
UIImage *image = [[UIImage alloc] initWithData:imageData];
mChartImageView.frame = CGRectMake(0,0, 600, 300);
myScrollView.contentSize = mChartImageView.frame.size;
[myScrollView setMinimumZoomScale:-1.0];
[myScrollView setMaximumZoomScale:4.0];
[myScrollView setScrollEnabled:YES];
[myScrollView setContentSize:CGSizeMake(mChartImageView.frame.size.width, mChartImageView.frame.size.height)];
mChartImageView.image = image;
[image release];
}
[pool release];