1、首先缓存图片,等待后面利用本地url来取

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            TTURLCache *cache = [TTURLCache sharedCache];

            for (NSDictionary *item in results) {

                if (![cache hasDataForKey:[item objectForKey:@"thumb_url"] expires:3000]) {

                    [cache storeData:[NSDatadataWithContentsOfURL:[NSURLURLWithString:[item objectForKey:@"thumb_url"]]] forURL:[item objectForKey:@"thumb_url"]];

                }

            }        

        });

 

2、利用本地url来取图片

TTURLCache *cache = [TTURLCachesharedCache];

    NSMutableArray *photoResource = [NSMutableArrayarray];

    for (NSDictionary *item in wallRequestResults) {        

        UIImage *imagePNG = [UIImage imageWithData:[cache dataForURL:[item objectForKey:@"thumb_url"]]];

        NSString *tempURL = [[TTURLCache sharedCache] storeTemporaryImage:imagePNG toDisk:NO];        

        Photos *photo = [[Photos alloc] initWithURL:[item objectForKey:@"url"] smallURL:tempURL size:CGSizeMake(320, 480)];

        [photoResource addObject:photo];

        TT_RELEASE_SAFELY(photo);

    }

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2021-09-08
相关资源
相似解决方案