标签: sdwebimage

当服务器上的图像文件发生变化时,我的应用程序中的SDWebImage缓存图像会发生什么?

我正在使用该SDWebImage库在我的应用程序中缓存Web图像:

https://github.com/rs/SDWebImage/blob/master/README.md

目前的用法:

[imageView setImageWithURL:[NSURL URLWithString:profilePictureUrl] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
Run Code Online (Sandbox Code Playgroud)

我的问题是,一旦图像被缓存后会发生什么,然后几天后,服务器上的图像文件已用新图像更新?

目前我的应用程序仍在显示缓存的图像.

我无法在任何有关设置缓存超时的文档中看到或识别出文件大小已更改的内容.

如果有人有使用这个特定库的经验,那么任何帮助将不胜感激.

提前致谢.

iphone caching objective-c uiimageview sdwebimage

48
推荐指数
5
解决办法
3万
查看次数

SDWebImage清除缓存

我正在显示从Web下载的图标列表,其中包含表格视图中的文本.可以在服务器端更改图标,我需要在新图标可用时立即更换它们.我尝试使用以下代码:

[imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"table_avatar_icon"] options:SDWebImageCacheMemoryOnly];
Run Code Online (Sandbox Code Playgroud)

并调用[[SDImageCache sharedImageCache] clearMemory];我的刷新回调,但它不会清除缓存的内容.更重要的是,即使我关闭应用程序并再次打开它,图像仍然存在.

我发现只有一种方法可以清除缓存,而是通过调用[[SDImageCache sharedImageCache] clearDisk];.这仅在我关闭并重新打开应用程序后才有效.

如何强制SDWebImage不使用磁盘缓存?

iphone objective-c ios sdwebimage

34
推荐指数
2
解决办法
3万
查看次数

在SDWebImage中显示活动指示器

我正在使用SDWebView图像,我想显示一个活动指示器作为占位符,同时从远程获取图像.

我在这里尝试了Malek的答案如何在SDWebImage中显示活动指示器,但似乎如此

UIImage *cachedImage = [manager imageWithURL:url];
Run Code Online (Sandbox Code Playgroud)

已弃用.

是否有人使用此库可以告诉我如何在加载图像时插入活动指示器?

编辑

根据Michael Frederick的指示,我最终得到了这段代码,一切正常.

UIActivityIndicatorView *activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.hidden = NO;
[activityIndicator startAnimating];
activityIndicator.center = CGPointMake(self.tipImage.frame.size.width /2, self.tipImage.frame.size.height/2);
[imageView setImageWithURL:[NSURL URLWithString:imageString]
          placeholderImage:nil options:SDWebImageProgressiveDownload
                   success:^(UIImage *image) { [activityIndicator stopAnimating];[activityIndicator removeFromSuperview]; }
                   failure:^(NSError *error) {  [activityIndicator stopAnimating];[activityIndicator removeFromSuperview]; }];

[imageView addSubview:activityIndicator];
Run Code Online (Sandbox Code Playgroud)

objective-c uiactivityindicatorview sdwebimage

31
推荐指数
8
解决办法
2万
查看次数

使用Swift 3模糊地使用'sd_setImage(with:placeholderImage:completed :)'

我正在使用SDWebImagemy 进行以下调用imageView,它可以正常工作Swift 2但在XCode 8 beta 5编译时出错Swift 3:

 imageView.sd_setImage(with:url, placeholderImage:placeholder, completed: {
    (image: UIImage?, error: Error?, cacheType: SDImageCacheType, imageURL: URL?) in
            ...
    });
Run Code Online (Sandbox Code Playgroud)

错误是:

模糊地使用'sd_setImage(with:placeholderImage:completed :)'

我怀疑我在完成的处理程序的签名中有问题,但我无法弄清楚语法应该是什么.我错过了什么?

ios sdwebimage swift3 xcode8

28
推荐指数
2
解决办法
1万
查看次数

SDWebImage下载图像并存储到密钥缓存

您好我在项目中使用SDWebImage框架,我想下载和缓存图像,但我想我的代码是将图像存储在缓存中两次?有没有办法只用一次键将图像存储在缓存中?这是我的代码.

         SDWebImageManager *manager = [SDWebImageManager sharedManager];
         [manager downloadWithURL:[NSURL URLWithString:url] options:0 progress:^(NSUInteger receivedSize, long long expectedSize) {

          } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {

            if(image){
                NSString *localKey = [NSString stringWithFormat:@"Item-%d", i];
                [[SDImageCache sharedImageCache] storeImage:image forKey:localKey];
            }

          }];  
Run Code Online (Sandbox Code Playgroud)

有什么我错过了吗?看起来在我的分配工具中这样做会增加大量内存.

objective-c uiimage sdwebimage

23
推荐指数
6
解决办法
4万
查看次数

iOS App冻结在PushViewController上

我的导航控制器间歇性地在推动时冻结.它似乎将新的视图控制器添加到堆栈中,但动画永远不会发生.我还有两个其他容器在屏幕上保存视图控制器,我可以在导航控制器冻结后很好地与它们进行交互.真正有趣的是,如果我尝试将另一个视图控制器推到导航控制器的堆栈上,我注意到堆栈顶部有一个额外的视图控制器(我最初推动的视图控制器冻结了导航控制器).所以,如果我在主屏幕上(我们将其称为VC-Home)并尝试推送新视图(VC-1)并冻结,那么我尝试推送新视图(VC-2),这是我在推送之前在当前堆栈中看到的内容:

{ [VC-Home, VC-1] }

并且在调用pushViewController之后,它保持不变; VC-2未添加到堆栈中.

据我所知,导航控制器通过在动画开始之前使前一个视图控制器处于非活动状态来启动动画,但随后动画永远不会发生,导航控制器处于冻结状态.

我正在通过调用从故事板创建新的视图控制器, UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController")所以我认为那里没有任何问题.我也没有在导航栏上覆盖pushViewController.关于我的应用程序的一些独特的东西是,它是非常高解析度图像重(使用SDWebImage来管理),我总是在屏幕上有三个容器在一次(一个导航控制器,用于搜索一个视图控制器,以及一个互动排水沟/侧面/滑出菜单).

CPU使用率低且内存使用率正常(发生冻结时设备稳定在60-70MB左右).

是否有任何想法可能导致这个或任何调试技巧可以帮助我发现真正的问题?

更新

UINavigationController没有唯一的代码,因为我只是推动使用pushViewController().这是调用它的代码:

func didSelectItem(profile: SimpleProfile) {
     let vc = UIStoryboard.profileViewController()
     vc.profile = profile
     navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

我推送的ViewController在viewDidLoad中有以下代码:

override func viewDidLoad() {
    super.viewDidLoad()
    button.roundView()

    if let type = profile?.profileType {
        //load multiple view controllers into a view pager based on type 
        let viewControllers = ProfileTypeTabAdapter.produceViewControllersBasedOnType(type)
        loadViewPagerViews(viewControllers)

        let topInset = headerView.bounds.height + tabScrollView.contentSize.height
        if let viewPager = viewPager {
            for view in viewPager.views {
                if …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios sdwebimage swift

23
推荐指数
2
解决办法
5492
查看次数

SDWebImage和设置自定义HTTP标头?

我刚刚将用于缓存图像的代码从EGOImageCache更改为SDWebView.不幸的是我不知道如何设置自定义HTTP标头,因为我必须发送身份验证才能获取图像.使用EGOImageCache很容易,因为我已经在适当的地方扩展了NSURLRequest.但是我不知道如何使用SDWebView.framework来做到这一点.我看到标题,我在SDWebImageDownloader.h中找到了包含的方法

    /**
 * Set a value for a HTTP header to be appended to each download HTTP request.
 *
 * @param value The value for the header field. Use `nil` value to remove the header.
 * @param field The name of the header field to set.
 */
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;

/**
 * Returns the value of the specified HTTP header field.
 *
 * @return The value associated with the header field field, or `nil` if there is no …
Run Code Online (Sandbox Code Playgroud)

uiimageview image-caching http-headers sdwebimage

20
推荐指数
1
解决办法
9389
查看次数

使用SDWebImage在服务器上更改映像时如何更新缓存中的映像

我正在使用SDWebImage库从服务器下载图像. https://github.com/rs/SDWebImage

当使用相同的URL在服务器上更新映像时,SDWebImage无法更新缓存的映像.

caching objective-c ios sdwebimage

18
推荐指数
3
解决办法
1万
查看次数

如何清除从SDWebImage加载的所有缓存图像?

我通过SDWebImage在我的应用程序上加载了所有图像.下载和缓存工作得很好,但我想制作一个按钮,可以清除整个应用程序中的所有缓存图像.

我的一个标签栏视图上有一个"清除缓存"按钮作为UIButton.如何点击此按钮,所有缓存的图像都被删除并需要重新下载?

使用Swift.

谢谢!

caching ios sdwebimage swift

18
推荐指数
1
解决办法
1万
查看次数

如何在SDWebImage中显示活动指示器

目前我正在通过以下方式将SDWebImage集成到我的项目中

1)#import"UIButton + WebCache.h"

2)[button setImageWithURL:url placeholderImage:[UIImage imageNamed:@"no_photo.png"]];

因此,它将在相应按钮上方显示URL中显示的图像列表.

但是现在我想在下载图像时在按钮上方显示一个活动指示器,那么我该怎么做呢?

iphone uiactivityindicatorview sdwebimage

16
推荐指数
3
解决办法
2万
查看次数