我使用下面的代码来获取一些图像,这些图像将被放入一个表视图中。但这需要很长时间(5-6秒)才能得到30张图片。
有没有更聪明/更快的方法来做到这一点?
NSString *imageUrl = ......;
NSString *urlStr =
[imageUrl UrlstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *path = [[NSString alloc] initWithFormat:@"http://xxx.dk/xml.aspx%@", urlStr];
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
return img;
[..... release];发布于 2013-04-11 18:15:32
这里的profileimg是来自Api的get,String name
NSString *profileimg=[Check objectForKey:@"IMAGE"];
imageview.image=[[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:profileimg]]];发布于 2010-11-02 17:58:40
我宁愿在屏幕上出现单元格时下载图像数组中的每个新图像,如果第二次屏幕上出现单元格(即该单元格的图像已经下载),则只显示已经保存的图像。
发布于 2010-11-02 18:51:52
使用异步加载图像。查看以下示例代码:http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
https://stackoverflow.com/questions/4076434
复制相似问题