【发布时间】:2011-04-20 15:14:11
【问题描述】:
我尝试显示由 Google Chart API 返回的图像,但以下代码不起作用:
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World"]];
UIImage *downloadedImage = [UIImage imageWithData:imageData];
imgView.image = downloadedImage;
或
NSData *imageData=[NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World"]] returningResponse:nil error:nil];
UIImage *downloadedImage = [UIImage imageWithData:imageData];
imgView.image = downloadedImage;
目标图像未按预期显示。你知道问题出在哪里吗?
【问题讨论】:
标签: api nsurlconnection charts nsurl