我希望能够离线查看我的应用程序以及我的表中的所有图像。目前我所有的图像都被缓存。但不是实际的结果表格。图像缓存表
NSMutableArray *images;
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://xxxxxxx.co.uk/jsonimages.php"];
NSData *jsonData = [NSData dataWithContentsOfURL:url];
NSError *error = nil;
if (jsonData) {
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers error:&error];
images = result[@"images"];
}
}
所以,让我像一个网址列表,然后我有我的表是这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
[cell.thumbnailImageView setImageWithURL:[NSURL URLWithString:encodedString]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
}
用于缓存encodedString
使用SDWebimage
但是,如果我去到应用程序没有任何访问互联网的图像没有出现。这是因为我需要缓存数组?
只需使用** ** AMAZING DLImageLoader。完整的代码示例.. http://stackoverflow.com/a/19115912/294884 – Fattie