Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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 脱机时SDWebImageView缓存问题以及转义URL的百分比_Ios_Objective C_Sdwebimage_Nsurlcache - Fatal编程技术网

Ios 脱机时SDWebImageView缓存问题以及转义URL的百分比

Ios 脱机时SDWebImageView缓存问题以及转义URL的百分比,ios,objective-c,sdwebimage,nsurlcache,Ios,Objective C,Sdwebimage,Nsurlcache,我正在使用SDWebImage异步显示图像,并缓存它们,然后在脱机模式下获取它们 在使用脱机模式时,我遇到了SDWebImageDownloader和UIImageView+WebCache缓存的问题,并且该问题仅在处理转义URL百分比时出现,转义URL具有一些特殊字符,如“{” 在联机模式下,一切正常,但在脱机模式下,不加载URL包含转义百分比的图像 [myImageView setImageWithURL:[urlImage percentEscapedURL]

我正在使用
SDWebImage
异步显示图像,并缓存它们,然后在脱机模式下获取它们

在使用脱机模式时,我遇到了
SDWebImageDownloader
UIImageView+WebCache
缓存的问题,并且该问题仅在处理转义URL百分比时出现,转义URL具有一些特殊字符,如“{”

在联机模式下,一切正常,但在脱机模式下,不加载URL包含转义百分比的图像

[myImageView setImageWithURL:[urlImage percentEscapedURL]
                   completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                       //image here is loaded in offline mode only if its URL does not need percent escapes
                   }];
SDWebImageDownloader
也存在同样的问题

我试图调试
SDImageView
行为,它似乎在使用iOS SDK
nsCachedUrResponse
行为

我正在用iOS 7.0进行测试


任何人都有相同的问题?有解决方法吗?

SDWebImage在
SDWebImageManager.h
中声明了一些属性:

@property (strong) NSString *(^cacheKeyFilter)(NSURL *url);
相应文件中有此属性的说明:

/**
 * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can
 * be used to remove dynamic part of an image URL.
 *
 * The following example sets a filter in the application delegate that will remove any query-string from the
 * URL before to use it as a cache key:
 *
 * @code

[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) {
    url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path];
    return [url absoluteString];
}];

 * @endcode
 */

我认为您可以尝试在相应的代码中做一些更改。

什么是
percentEscapedURL
?@SergeyNikitin在我的NSString类别中,只有在需要时才能获得百分比转义URL:-(NSURL*)percentEscapedURL{NSURL*URL=[nsurlurlwithstring:self];if(URL==nil){URL=[nsurlwithstring:[self stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];}返回url;}