Giter VIP home page Giter VIP logo

uiactivityindicator-for-sdwebimage's Introduction

UIActivityIndicator-for-SDWebImage

The easiest way to add a UIActivityView to your SDWebImage view

Installation

If you're using CocoaPods (You are not?! You should!!) just add

pod 'UIActivityIndicator-for-SDWebImage'

into your Podfile file.

Alternatively, copy the class (.h and .m) into your application.

Usage

You can use all the standard SDWebImage methods... adding the last parameter

usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle 

So all the methods available are:

- (void)setImageWithURL:(NSURL *)url usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;

Remove the activity indicator

Sometimes it's useful to remove the activity indicator (for example when you call cancelCurrentImageLoad on the UIImageView). From now on the method removeActivityIndicator is public: fell free to use it!

Why?

Well, apparently SDWebImage team doesn't want a UIActivityIndicatorView... (actually I found a bug in that commit, but I don't think this is why they closed the issue)

Why? I don't know.

And why a category instead of a fork? Well, I really don't want to keep this repo updated with the (future) new SDWebImage commits (obvious, right?).

Ok, but we could modify our SDWebImage repo with these differences Yes... unless you're using Cocoapods! If you're doing it you should know that you can't modify a repo, because at the next update, Cocoapods will delete all your work (pulling the new version and removing all your changes). So with a category you can keep your SDWebImage pod updated without problems :)

License

UIActivityView for SDWebImage is released under the MIT License. Please see the LICENSE file for details.

uiactivityindicator-for-sdwebimage's People

Contributors

chasseurmic avatar jjsaccolo avatar ks-simakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uiactivityindicator-for-sdwebimage's Issues

Complete closure is called 4 times per image

I use the following code in an `init()`` constructor:

    if let url: NSURL = NSURL(string: previewCard.getImageUrls().getWithInt(0) as! String) {
      self.imageView?.setImageWithURL(url, placeholderImage: MGImage.imageWithColor(UIColor.clearColor()), options: SDWebImageOptions.RefreshCached, completed: { (image:UIImage!, error:NSError!, type:SDImageCacheType, loadUrl:NSURL!) -> Void in

        println("-------------- done")
        }, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)

    }

The console output is:

 println("-------------- done")
 println("-------------- done")
 println("-------------- done")
 println("-------------- done")

Why is the complete closure called four times? Is this a bug?

Integrate with SD WebImage

You wrote:

You can use all the standard SDWebImage methods... adding the last parameter
usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle

I tried:

    cell.logoImageView.sd_setImageWithURL(logoUrl, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)

but got the error:

Cannot invoke 'sd_setImageWithURL' with an argument list of type '(NSURL, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle)'

extra code need to be comment

hi
i just use this
it's a awsome plugin for SDWebImage
but when i using, i fount that some code needed to be comment
such as
[self setImageWithURL:url
placeholderImage:placeholder
options:options
progress:progressBlock
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
//completedBlock(image, error, cacheType);
[weakSelf removeActivityIndicator];
}
];

completedBlock(image, error, cacheType); this part need to be comment, and didn't impact using

Memory leak in UIImageView+UIActivityIndicatorForSDWebImage.m

I ran Instruments on an app that I'm developing and I get multiple leaks at line 27:

 activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:activityStyle];

I'm using the category on SDWebImage for imageViews inside a collection view.

Activity Spinner Not Centered

After adding in your library, the activity icon is in the upper left, instead of the center. Never had this issue before. Any suggestions? Have autolayout enabled.

Code I am using:

self.image.contentMode = UIViewContentModeScaleAspectFit;

[self.image setImageWithURL:[NSURL URLWithString:imageString]
placeholderImage:nil
options:SDWebImageRefreshCached
usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

img_0075

Update SDWebImage

SDWebImage updated to 3.7.3 but UIActivityIndicator-for-SDWebImage requires specifically 3.7.0. Can you update the podspec please?

removeActivityIndicator

Hello and thanks for the excellent category.
What i am facing is that the activity only shows for the images i see on screen when i first load the view.
Then as i scroll down the activity indicator is not showing any more.
i checked the code and when the image completes you have:
[weakSelf removeActivityIndicator];
which removes the activity from the superview.
However this does not make it nil so next time it calls this
[self createActivityIndicatorWithStyle:activityStyle];
the code does not go inside the if ([self activityIndicator] == nil) { ....
but directly goes to this:
[self.activityIndicator startAnimating];
which will not work since the indicator is already removed from the superview.

if i add this:
self.activityIndicator = nil;
underneath the [[self activityIndicator] removeFromSuperview];
in the removeActivityIndicator method then i can see the loader for all images.

am i missing something else?
Does it make sense?

thanks
Konstantinos

Invalid context error

CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

cocoapods / swift and SDWebImage imports

I tried to install UIActivityIndicator-for-SDWebImage through cocoapods and use it in a Swift project.
As far as I checked pod install did its job correctly and UIActivityIndicator-for-SDWebImage links to SDWebImage.framework.
In my project I

import SDWebImage
import UIActivityIndicator_for_SDWebImage

but the Swift compiler issues an error trying to build the Objective-C module UIActivityIndicator-for-SDWebImage.
That error being it not finding UIImageView+WebCache.h at its import statement in UIImageView+UIActivityIndicatorForSDWebImage.h, which looks like this:

#import "UIImageView+WebCache.h"

I referred to the guide to cocoapods frameworks and after modifying the failing import statements to

#import <SDWebImage/UIImageView+WebCache.h>
#import <SDWebImage/SDImageCache.h>

(SDImageCache.h was failing too) it compiled.

I'm not experienced enough with the iOS toolchain and cocoapods yet to know whether the library files should actually be updated or if something is wrong with my project configuration, so "please advise" :)

Thanks!

Possible to not use method version?

So I currently have SDWebImage implemented this way.

[imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"]
placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"]
options:SDWebImageRefreshCached];

I tried adding the "usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle" after the options, but am getting an error

"Use of undeclared identifier 'activityStyle'"

Anyway around this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.