Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 有没有办法通过Haneke预取图像?_Ios_Objective C_Haneke - Fatal编程技术网

Ios 有没有办法通过Haneke预取图像?

Ios 有没有办法通过Haneke预取图像?,ios,objective-c,haneke,Ios,Objective C,Haneke,在SDWebImage中,可以预先预取(提前加载)图像,如下所示: [[SDWebImagePrefetcher sharedImagePrefetcher] prefetchURLs:<NArray with image URLs>]; [[SDWebImagePrefetcher sharedImagePrefetcher]预取URL:]; 请问,有没有一种方法可以达到同样的效果 似乎有一个,但不确定如何使用它,例如,HNKPreloadPolicyAll我今天需要这个功能,

在SDWebImage中,可以预先预取(提前加载)图像,如下所示:

[[SDWebImagePrefetcher sharedImagePrefetcher] prefetchURLs:<NArray with image URLs>];
[[SDWebImagePrefetcher sharedImagePrefetcher]预取URL:];
请问,有没有一种方法可以达到同样的效果


似乎有一个,但不确定如何使用它,例如,
HNKPreloadPolicyAll

我今天需要这个功能,我发现,如果你在URL数组中循环并使用临时UIImageView调用hnk_setImageFromURL,图像就会被缓存

- (void) cacheImagesInURLs:(NSArray <NSString*>*)array;
{
    for (NSString *path in array) {
        UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kMaxWidth, kMaxHeight)];
        tempImageView.hnk_cacheFormat = [self setImageCacheFormat];

        [tempImageView hnk_setImageFromURL:[NSURL URLWithString:path] placeholder:nil];
    }
}
-(void)cacheImagesInURLs:(NSArray*)数组;
{
for(NSString*数组中的路径){
UIImageView*tempImageView=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,kMaxWidth,kMaxHeight)];
tempImageView.hnk_cacheFormat=[self-setImageCacheFormat];
[tempImageView hnk_setImageFromURL:[NSURL URLWithString:path]占位符:nil];
}
}
如果SDWebImage不适合您,您也可以查看。