Code Monkey home page Code Monkey logo

asyncimageview's People

Contributors

jweyrich avatar keeshux avatar nicklockwood 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  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

asyncimageview's Issues

Unable to clear cache

First of all I wanted to thank you and congratulate for this code. It's been very helpful.

I'm displaying an image on an UIImageView using the imageFromUrl method. The image loads great, but after doing an action the image loaded previously get refreshed on the server and I would like to download the newest version of that image. I've tried to clear the cache in different ways but I don't get the image latest version unless I restart the app.

The latest thing I've tried is the following, still no luck trying to clear the cache.

NSURL *url = [NSURL URLWithString:[user photo]];

[AsyncImageLoader sharedLoader].cache = nil;
[[AsyncImageCache sharedCache] removeImageForURL:url];

 self.pictureImageView.imageURL = url;    // Still getting previous version of the image

Thanks

When using AsyncImageLoader's LoadImageWithURL methods, the method simply returns

Unless I'm mistaken, upon first usage of a line such as: [[AsyncImageLoader sharedLoader] loadImageWithURL: someURLHere], it works the first time and AsyncImageLoadDidFinish or AsyncImageLoadDidFail are posted. However, when trying a second time, if the image is already in the cache, then the method returns without posting any notifications.

I did a quick fix by adding following notification post after the success check:

- (void)loadImageWithURL:(NSURL *)URL target:(id)target success:(SEL)success     failure:(SEL)failure
{
    //check cache
    UIImage *image = [_cache objectForKey:URL];
    if (image)
    {
        [self cancelLoadingImagesForTarget:self action:success];
        if (success)
            [target performSelectorOnMainThread:success withObject:image waitUntilDone:NO];


        [[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish
                                                        object:nil
                                                      userInfo:    [NSDictionary dictionaryWithObjectsAndKeys:image, @"image", nil]];

    return;
}

....

}

This seems to do the trick for me and was wondering if this is an issue or am I misunderstanding the AsyncImageLoader usage. Thanks.

Losing images when app is restarted

I am using AsyncImageView in my project. The issue for me is the images are removed from cache once the app is closed. How can I avoid this. how to retain images in cache until its manually removed?

-[UIImageView setImageURL:]: unrecognized selector sent to instance

I am using Xcode 4.3.2 with iOS 5.1 Simulator.

in init
newsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(21, 72, 277, 185)];
newsImageView.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:newsImageView];

in a method
newsImageView.imageURL = [NSURL URLWithString:@"http://timesofindia.indiatimes.com/photo/12459691.cms"];

Please help me out with this

Thanks
Arun

error: 'AsyncImageView' is ambiguous for type lookup in this context

When using AsyncImageView 1.5.1 and Spring https://github.com/MengTo/Spring, both as pods in a Swift project, the following compile-time error occurs:

error: 'AsyncImageView' is ambiguous for type lookup in this context
    @IBOutlet weak var myvariable:AsyncImageView!
                                  ^~~~~~~~~~~~~~
AsyncImageView.AsyncImageView:1:29: note: found this candidate
@objc(AsyncImageView) class AsyncImageView : UIImageView
                            ^
Spring.AsyncImageView:1:13: note: found this candidate
@objc class AsyncImageView : UIImageView

The traditional tool to fix such problems is separate namespaces, but there are no namespaces.

Based on similar problem Haneke/HanekeSwift#147 and instructions in https://github.com/raywenderlich/swift-style-guide#class-prefixes or http://stackoverflow.com/questions/24214863/swift-class-prefix-needed, I tried to prefix the type specification like this:

@IBOutlet weak var myvariable:AsyncImageView.AsyncImageView!

but it produced the exact same error message.

How to use both pods in a project ?

Unable to set UIImage instead able to set UIImageView

Hi,
I have this code to show you that is not working I don't know why.

UIImageView *URL_image=[[UIImageView alloc]initwithFrame:btnRect];
image.imageURL=someurl.jpg;
[self.view addSubview: URL_image]; // Able to add subview with image

UIImage *image1=URL_image.image;
[Bookbtn setBackgroundImage:imge1 forState:UIControlStateNormal]; // Not working.

I'm not able to set the background image of the button which I fetched from the URL.

Do you know how to just set the image to UIImage object instead of UIImageView.

caching problem

I have a tableview and it has imageviews inside its rows. Thanks to the asyncimageview library I can successfully lazy load the images so there is no problem. But I have questions about the caching property of that library.

What I expect from cache, for example I push to a view controller which has my tableview for the first time, it lazy loads the images with that library. However, when I go back from that view and go push again, if noting is changed, I think it should retrieve the images from the cache. Not necessary to download the images again. But in this library it downloads the images again. Do I need to do something extra to do it? or it is not possible to have that kind of caching property at all?

Placeholder image is not replaced

before i load the image i write

self.image = [UIImage imageNamed:@"placeholder"]

placeholder is packed into the bundle

and then i do

[[AsyncImageLoader sharedLoader]loadImageWithURL:[self loadLogo:logoURL] target:self action:@selector(showLogo:)];

-(void)showLogo:(UIImage *)image{
[self.logo setImage:image];
}

the problem is i can see the placeholder behind the image loaded from the url, the placeholder is significantly larger than the requested image in this case

is it something i'm doing wrong or the library misbehaving ?

Multiple calls to "loadImageWithURL: target: action:" does not always call action

When I call "loadImageWithURL: target: action:" multiple times, the action is not triggered for each call. (if I add a "failure" selector, it is not called either).

Here is my code:

for (id item in urls) {
    NSURL *url = [[NSURL alloc] initWithString:(NSString *)item];
    [[AsyncImageLoader sharedLoader]
                         loadImageWithURL:url
                         target:self
                         action:@selector(loadImage:withURL:)];
 }

In my code, "urls" contains around 10 Strings, mais the "loadImage:withURL:" selector is called only 3 or 4 times (and if I add a failure selector, it's never called).

I think it's because of a max number of connections, but I expected them to be queued, or maybe I am doing something wrong.

Thanks

use ImageURL after a certain process completes

Hi,

I followed your suggestion to use AsyncImageView class for loading images on a background thread. However I came upon another issue. In my program, before I set the imageview, I have to call my web service via AsiHTTPRequest asynchronously, which pre-renders a certain image for me (this takes about 0.25 seconds per image).

So in carousel's viewForItemAtIndex I do this:

UIImageView *imgView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"noImageCarousel.png"]] autorelease];
[[Globals sharedGlobals] generateImageForIndex:index];

The second line starts the asynchronous request, which calls my web service, and receives a reply that the image has been created and is now stored on the server.

Then in the didfinishselector of the former request I do this:

UIImageView *imgView = (UIImageView *)[galleryCarousel.carousel itemViewAtIndex:[index intValue]];
[[AsyncImageLoader sharedLoader] cancelLoadingURL:imgView.imageURL];
imgView.imageURL = [self smallImageURLAtIndex:[index intValue]];

The problem is that imageURL method is never entered into and nothing is updated. I tried putting a breakpoint in the code of the setImageURL but it is never reached.

I don't know if this is an issue or my bad coding :)

Using loadImageWithURl and call backs?

Hi there,
A great library indeed. It works flawlessly when i set imageURL to load a remote image.

However, i would like to have a placeholder image, and change it to an error image if the URL fails loading.
Can somebody give a quick snippet on how to use loadImageWithURL?

Thanks a bunch

UIimage *image =asynceImage.image sometime return invalided image

Thank you nick,

  1. AsyncImageView *asyncImageView = alloc... init...
  2. asyncImageView setImageURL( image url)

After I received AsyncImageLoadDidFinish from NSNotificationCenter

I save asyncimage.image at mydocument..

and saveMethod like
dispatch_async(dispatch_get_global_queue(0, 0), ^{ asyncimage.image save to disk }

It is Ok, but sometimes invalided Image saved

normally image file size > 1kb but invalided image file size < 1kb and it can't loading

I think "AsyncImageLoadDidFinish" message response time is faster then "real download image time"

how can I save asyncImageView.image to disk safely?

Thanks

Slow page loads...

Hello Nick,

First of all, I wanted to thank you for sharing your code. It’s been very helpful to me and I couldn't have started my project without it.

I have a UITabBarController with a small image (about 80kb each) on each tab. However, it takes between 2-5 seconds (strangely longer on WiFi then on 3G) to switch from tab to tab and the placeholder image is either visible for a split second or not at all. Based on your example project; it should switch tabs instantly and show the placeholder image for as long as it takes to download the image. Unfortunately in my project it seems to be downloading the image first, then switching tabs. The same issue is happening with a UITableView in my project.

I’m sure it's something I’m doing wrong in my own code as I'm still new to obj-C but I thought I’d ask you to see if this is a issue you’ve come across before.

I’m using your code to load images into a UIImageView (acting as a button) and a UITableView.

UIImageView Code:


NSDictionary *imagePaths = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"someURL"]];
    
pathString = [[imagePaths objectForKey:@"cells"] objectForKey:@"cellButton"];

[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView.imageURL];
    
imageView.image = [UIImage imageNamed:@"adPlaceholder.png"];

imageView.imageURL = [NSURL URLWithString:pathString];
    
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(mainAd) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0.0, 0.0, 320.0, 45.0)];
    
[imageView addSubview:button];
    
imageView.userInteractionEnabled = YES;

UITableViewCode:



// Before tableView cellForRowAtIndexPath

NSDictionary *imagePaths = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"someURL"]];

eventArray = [imagePaths objectForKey:@"cells"];

NSMutableArray *URLs = [NSMutableArray array];
for (NSString *path in [imagePaths objectForKey:@"cellImages"])
{
   NSURL *URL = [NSURL URLWithString:path];
    if (URL)
       {
            [URLs addObject:URL];
        }
        else
        {
            NSLog(@"'%@' is not a valid URL", path);
        }
    }
self.imageURLs = URLs;

//In tableView cellForRowAtIndexPath

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imageView];
    
cell.imageView.image = [UIImage imageNamed:@"Placeholder90.png"];
    
cell.imageView.imageURL = [imageURLs objectAtIndex:indexPath.row];

If you could help me out I’d really appreciate it.

Thanks

AsyncImageConnection falls with double free

When deallocated AsyncImageConnection falls on AH_RELEASE(URL) with double free error.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *menuCellIdent = @"menuCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:menuCellIdent];
    if (nil == cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:menuCellIdent] autorelease];
        CGRect frm = CGRectMake(0, 0, 320, tableView.rowHeight);
        AsyncImageView *imView = [[AsyncImageView alloc] initWithFrame:frm/*cell.contentView.frame*/];
        imView.imageURL = [NSURL URLWithString:[((NLYContentElement *)[self.elements objectAtIndex:indexPath.row]) picture] relativeToURL:[NSURL URLWithString:ONLY_SERVER]];
        [cell.contentView addSubview:imView];
        [imView release];
    }
    else {
        for (UIView *imV in cell.contentView.subviews) {
            if ([imV isKindOfClass:[AsyncImageView class]]) {
                ((AsyncImageView *)imV).imageURL = [NSURL URLWithString:[[self.elements objectAtIndex:indexPath.row] picture] relativeToURL:[NSURL URLWithString:ONLY_SERVER]];
            }
        }
    }
    return cell;
}

this is only method, I use AsyncImageView in. BaseSDK - iOS5.
Error ocured on iOS 4.0.1 simulator and iOS 4.2.1 iPod2 hardware

ImageView loading some different cell image iOS 8

Please note this issue is happening only on iOS 8.0+

I have a collection view controller located in one tab(single page only right now, so cells are not actually reused). When I first go to this tab the first icon loads exact image, but as soon as it loads the 5th icon, it replaces 1st icon image with this first image, when I come back to this tab again(which is again refreshing), it sets it right. This issue is happening only with iOS 8.

  • (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
    KBGameCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GameCell" forIndexPath:indexPath];

    EBOXAppInfo *content = (EBOXAppInfo *)_gAppData.platformApps[indexPath.item];

    NSURL *iurl;
    iurl = content.urlIconImage;
    NSLog(@"URL for app : %@ : %@ ",content.name, iurl);

    cell.appIcon.image = nil;
    [cell.appIcon setShowActivityIndicator:YES];
    cell.appIcon.imageURL = iurl;
    [cell.appName setText: content.name];

    NSString *categoriesText = [_gAppData localizedCategoriesForAppInfo:content];

    [cell.tagsLabl setText:categoriesText];
    cell.appIcon.imageURL = content.urlIconImage;

    return cell;
    }

iPhone 5s

Hi Guys,

The AsyncImageView is not working on a iPhone 5s device. I had to change the name of the first parameter into withImage. After that it works on a iPhone 5s.

Kind Regards, Nico Jansen

  • (void)setImage:(UIImage *)withImage
    {
    if (withImage != self.image && self.crossfadeDuration)
    {
    //jump through a few hoops to avoid QuartzCore framework dependency
    CAAnimation *animation = [NSClassFromString(@"CATransition") animation];
    [animation setValue:@"kCATransitionFade" forKey:@"type"];
    animation.duration = self.crossfadeDuration;
    [self.layer addAnimation:animation forKey:nil];
    }
    super.image = withImage;
    [self.activityView stopAnimating];
    }

Update ImageView frame when the loading completes

Hi,

I am trying to display the image in a UIScrollView and therefore need to update the contentsize and the bounds of the imageview to the actual size of the image being loaded.

I have implemented the [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imageLoaded:) name:AsyncImageLoadDidFinish object:nil];

and in this method imageLoaded I am trying to update the frame of the imageview.

The problem is that sometimes it updates, and sometimes not (i. e. sometimes the bounds stay the same as the dummy image's).

Since the images are loaded from the outside, their dimensions are often not known. Perhaps you could suggest how the holding view frame could be updated to match the size of the downloaded image?

Andrius

unrecognized selector exception

For some reason I'm getting an error when I set imageURL property.

Here is my code:
imageView = [[UIImageView alloc] initWithFrame:item.imageFrame];
imageView.imageURL = [NSURL URLWithString:item.items_image];

Here is the error log:
2011-09-27 17:20:48.473 app[41431:207] -[UIImageView setImageURL:]: unrecognized selector sent to instance 0x598bb20
2011-09-27 17:20:48.477 app[41431:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageURL:]: unrecognized selector sent to instance 0x598bb20'

Did I miss something? or am I doing something wrong?

Explicitly loaded images do not appear to be getting cached at all.

I need to load a lot of images, most of which will not be visible for several seconds until the user decides to scroll down. As such, I build up a list of all of their URLs and do something like:

[[AsyncImageLoader sharedLoader] loadImageWithURL:imageURL];

for each one. I can verify that this runs, that all the HTTP requests hit my server, and that the appropriate notifications are posted and received upon success by the loader.

However, when I scroll the view downward to reveal an AsyncImageView instance whose imageURL has been set to one of the very same URLs I supposedly just prefetched (yes, I've double checked that they are not different in any way other than their memory addresses), I get an indeterminate loading progress spinner inside that view rather than the instantaneous display I would generally get if it were, in fact, cached.

why not write to disk?

I think we can do like this.

  • (void)loadImageWithURL:(NSURL *)URL target:(id)target success:(SEL)success failure:(SEL)failure{
    //search at cache.if failed,search at disk.
    }
    //when image download is complete,write the data to disk in a new thread. I think it will help us to avoid the duplicate download.

warning about shadowed local variable

I know that's not a standard warning but I think it's a good idea to have it activated.

AsyncImageView.m:477:31: warning: declaration shadows a local variable [-Wshadow]
        AsyncImageConnection *connection = [_connections objectAtIndex:i];

You are using the connection name already outside of the loop in the same function

Massive Memory Consumption

When using the Category with imageView.imageURL = aNSURL;, the memory consumption is insane. For a set of 500 images, of around 30-60Kb each, of JPEG format (flickr api, q sized), the memory consumption shoots up by a staggering 60-80Mb.

These image views are subviews of UICollectionViewCells. So when scrolling, the previous images should be removed from the memory for the time being.

I've boiled down the issue to ImageIO not releasing the ImageIO_JPEG_DATA object.

Further google searches on this bit have shown that using imageWithContentsOfFile causes this a lot, but the category never uses it. The entire file doesn't. So I'm a little confused as to what may be causing this.

I hope you get a chance to look into this at the earliest.

App Crashes using AsyncImageVew

Thanks AsyncImageView is a perfect library for loading images asynchronously .
I have used this library many time but when I use to load many images in paging the app crashes. Its a memory problem I guess.

Here's my piece of code:

self.asyncImageView = [[AsyncImageView alloc]init];
self.asyncImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
self.asyncImageView.contentMode = UIViewContentModeScaleAspectFit;
self.asyncImageView.imageURL = [NSURL URLWithString: self.imageUrl];
self.asyncImageView.userInteractionEnabled = YES;
[AsyncImageLoader sharedLoader].cache = [AsyncImageLoader defaultCache];

[self addSubview : self.asyncImageView]; 

I have used asyncImage to page many images.

Thanks in advance

Image not loading, what had i done wrong ?

Hi Nick,

will you be able to tell me when had i gone wrong ?

the image is not showing, not event the UIIndicator

  • (void)imageViewPopup
    {
    UIImageView *selectorView = [[AsyncImageView alloc] initWithFrame:CGRectMake(0, 0, 250, 250.0f)];
    selectorView.contentMode = UIViewContentModeScaleAspectFit;
    selectorView.backgroundColor = [UIColor clearColor];

    [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:selectorView];
    // selectorView.image = [UIImage imageNamed:@"placeholder.png"];
    //selectorView.imageURL =[self.picsArray objectAtIndex:self.carouselView.currentItemIndex];

    ((AsyncImageView *)selectorView).imageURL = [self.picsArray objectAtIndex:self.carouselView.currentItemIndex];

    //NSLog(@"[self.picsArray objectAtIndex:self.carouselView.currentItemIndex]; %@",[self.picsArray objectAtIndex:self.carouselView.currentItemIndex]);

    UIImageView *imgView = selectorView;

    NSLog(@"imgView %@",selectorView);

    self.largeImgView=[[UIImageView alloc] initWithImage:[imgView.image copy]];
    self.largeImgView.frame=[imgView frame];

    [self.largeImgView setUserInteractionEnabled:YES];
    }

Not an ISSUE but a question about setting the .image property

I am using AsyncImageView with iCarousel and ReflectionView but I'm not sure of the best place within AsyncImageView to set the .image property (which appears to be necessary to get the reflection eventhough the image has already been downloaded from a remote URL). processDataInBackground seems like a good place but I must be missing something since it's not working for me.

Memory Leak issue when declared image.imageURL

Hi, firstly I'm glad to have such a good library to download images asynhcronously, and thank you for it.

I got the memory leak issue where ever I declare, on this line.

imageview.imageURL=[NSURL URLWithString:URLstring];

And i'm worried as I'm declaring it in many classes so it may create a crash for the applicaiton. Could you please help me out to fix this memory leak issue.

how can i save images in cache

In the method cellForRowAtIndexPath:

static NSString *CellIdentifier = @"kDAPeopleCell";

    UITableViewCell *cell = [self.myTabla dequeueReusableCellWithIdentifier:CellIdentifier];

   cell.selectionStyle = UITableViewCellSelectionStyleNone;

    for (NSInteger i = 0; i <IMAGES_PER_ROW; i++) {

        GridButton *button = (GridButton *)[cell viewWithTag:i+1];
        [button addTarget:self action:@selector(buttonPresed:) forControlEvents:UIControlEventTouchUpInside];
        [button setHidden:NO];

        DAProfile *profile = [self.profiles objectAtIndex:indexPath.row * IMAGES_PER_ROW + i];

        [button.nameAgeLabel setText:[NSString stringWithFormat:@"%@ (%d)",profile.firstName,profile.age]];
        [button.statusView setOnline:[profile.isOnline boolValue]];
        button.numberButton = indexPath.row * IMAGES_PER_ROW + i;

        //[button setImage: [UIImage imageNamed:@"user.png"]forState:UIControlStateNormal];


        //get image view
        AsyncImageView *asyncImageView = (AsyncImageView *)[cell viewWithTag:i+1*300];
        asyncImageView.contentMode = UIViewContentModeScaleAspectFill;
        asyncImageView.clipsToBounds = YES;

        //cancel loading previous image for cell
        [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:asyncImageView];

       // if (!asyncImageView.image) {

            //load the image
            NSURL *bgImageURL = [NSURL URLWithString:[arrayCeldasImages objectAtIndex:indexPath.row * IMAGES_PER_ROW + i]];
            NSLog(@"urlImage: %@", bgImageURL);

        if (bgImageURL != nil) {
            asyncImageView.imageURL = bgImageURL;

        }else{
           asyncImageView.image = [UIImage imageNamed:@"user.png"];
        }

      // }

        [asyncImageView setHidden:NO];
    }
    return cell;

Clearing images with crossfadeImages = YES

I'm using AsyncImageView objects with reusable cells in a UICollectionView. To reuse the cell I have to reset the images by setting them to nil. However, when crossfadeImages property is set to YES the image won't be reset.

The workaround is to set crossfadeImages to NO before setting the image to nil and then setting it back to YES.

I tried to change the setImage method in the following way but it didn't work. I was expecting that the transition with a nil image was causing the behavior but actually it's not.

- (void)setImage:(UIImage *)image
{
    if (_crossfadeImages && image)
    {
        //implement crossfade transition without needing to import QuartzCore
        id animation = objc_msgSend(NSClassFromString(@"CATransition"), @selector(animation));
        objc_msgSend(animation, @selector(setType:), @"kCATransitionFade");
        objc_msgSend(animation, @selector(setDuration:), _crossfadeDuration);
        objc_msgSend(self.layer, @selector(addAnimation:forKey:), animation, nil);
    }
    super.image = image;
    [_activityView stopAnimating];
}

Adding Asyncimageview with iCarousel

Hi

I have designed an app which uses asyncimage view and icarousel in that.Actually i am seeing an empty view no image in that.

  • (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
    {
    return downloadarray.count;
    }

  • (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(AsyncImageView *)view
    {
    if (view == nil)
    {
    view = [[[AsyncImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 320)] autorelease];

      view.image=[UIImage imageNamed:@"sample.png"];
      view.imageURL=[imageURLs objectAtIndex:index];
    

    }
    return view;

}

  • (CGFloat)carouselItemWidth:(iCarousel *)carousel
    {
    return ITEM_SPACING;
    }

ARC and iOS5

Hi there

I'd like to use this library with my iOS 5 project using ARC. What I've done is load the demo xCode Project and used xCode's "Convert to Objective-C ARC" option.

When I do that, I have to remove all of the explicit calls to "retain count" that I see such as

/*
for (int i = [connections count] - 1; i >= 0; i--)
{
    AsyncImageConnection *connection = [connections objectAtIndex:i];
    if ([connection.target retainCount] == 1)
    {
        [connection cancel];
        [connections removeObjectAtIndex:i];
    }
}*/

Once I do that, it seems to compile and run just fine... so the question is.. have you given thought to rewriting the library to be ARC compliant or is this a valid approach?

Thanks!

AsyncImageView loads only Partial or half image

Why the AsyncImageView loads half image here is the code and its simple may be you have to check it in the library
AsyncImageView *sync_image=[[AsyncImageView alloc]initWithFrame:button1Frame];
sync_image.imageURL=[NSURL URLWithString:Left_image_url];
[cell.contentView addsubview:sync_image];

could you please check this?

Lazy Loading UITableView sometimes shows previously queued image

I have a UITableView that is using your AsyncImageView (great stuff btw). If I scroll up and down, I often get a different image than was requested. It seems like it may be a problem with dequeing the proper cell. I usually have to scroll up and down a couple of times.

It seems like it comes when it should be showing default.

Image Caching Issue

Hello Nick,

I'm getting issues in caching image , on each app launch from background then image again start downloading but it should come from cache because in last app session i have downloaded image successfully so please let me know how to restrict the app to download the image again when come back from background.
Looking forward to your valuable feedback.

Random crashes on _connections array access

When loading multiple images the following crash randomly occurs (I'm still unable to reproduce it):

"index N beyond bounds [0 .. N-1]"

Example:

*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]

This is raised by the "imageLoaded:" and "imageFailed:" methods somewhere in the nested reverse loops.

I'll let you know if I get over that.

ImageView show another image

Hi

I create tableview with AsyncImageView (AIV) element in each cell, when i scroll the table, the AIV will somehow show image from other AIV's cell which already fully / partially loaded instead of load indicator, Sure it will return to its original assigned image after fully loaded, but before that, it will cause weirdness..

is this a bug?

processing images

I'd like to to process the images before caching them, for example resizing them o merging with other images to add shadow

why is AsyncImageConnection private? I would like to extend that class, and insert the processing in cacheImage or processDataInBackground

another solution could be to expose a cb called on the image before of cacheing it

AsyncImageLoadDidFinish doesnt get call if the image is cached

Hi, im adding a subview(1) while loading an image. When the image finished downloading i get a notification (AsyncImageLoadDidFinish). The problem is when the image is already cached that i get no notification, so the method that removes the subview(1) doesnt get fired. Any suggestion?

Image not Cache

Hey Nick,

I am not sure whether the implementation that I did is correct or not, the images not being cache every time when I re-run the app.

SingleDiscoverItemTVCell *cell = (SingleDiscoverItemTVCell *)[self.mainTableView dequeueReusableCellWithIdentifier:@"TVCellSingleDiscoverItem"];

if( cell == nil ){

    NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"SingleDiscoverItemTVCell"
                                                  owner:(id)self
                                                options:nil];
    cell = (SingleDiscoverItemTVCell *)nibs[0];
}

else {

    [cell showImagePlaceholder];
    [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.mainIV];
}
return cell;

cell.m

@property (nonatomic, weak) IBOutlet AsyncImageView *mainIV;

self.mainIV.imageURL = [NSURL URLWithString:@"the url"];

Random crashes in the imageLoaded: callback

I'm seeing sporadic crashes originating from the imageLoaded: call, doing something with KVO. I've been unable to reproduce this in the debugger, but I get these crash reports from production frequently. Anyone have a suggestion about what might be going on here? I'm not doing any manual cache management or anything fancy.

Thread 0 Crashed:
0   libobjc.A.dylib                     0x3a0965d0 _objc_msgSend + 16
1   CoreFoundation                      0x3238143d __CFStringAppendFormatCore + 11173
2   CoreFoundation                      0x3231c27d _CFStringCreateWithFormatAndArguments + 73
3   CoreFoundation                      0x323a02d7 +[NSException raise:format:] + 59
4   Foundation                          0x32c95a17 -[NSObject(NSKeyValueObserving) observeValueForKeyPath:ofObject:change:context:] + 79
5   Foundation                          0x32c955f3 NSKVONotify + 35
6   Foundation                          0x32c93b47 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 311
7   Foundation                          0x32c2fb85 NSKeyValueNotifyObserver + 273
8   Foundation                          0x32c2f7dd NSKeyValueDidChange + 337
9   Foundation                          0x32c09cbb -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 95
10  Tastemade                           0x00032ef1 -[AsyncImageLoader imageLoaded:] (AsyncImageView.m:399)
11  CoreFoundation                      0x322f1349 __CFXNotificationPost + 1421
12  Foundation                          0x32c08b7f -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
13  Tastemade                           0x00032041 -[AsyncImageConnection cacheImage:] (AsyncImageView.m:164)
14  Foundation                          0x32cb84a1 __NSThreadPerformPerform + 461
15  CoreFoundation                      0x323758f7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16  CoreFoundation                      0x3237515d __CFRunLoopDoSources0 + 213
17  CoreFoundation                      0x32373f2f __CFRunLoopRun + 647
18  CoreFoundation                      0x322e723d _CFRunLoopRunSpecific + 357
19  CoreFoundation                      0x322e70c9 _CFRunLoopRunInMode + 105
20  GraphicsServices                    0x35ec633b _GSEventRunModal + 75
21  UIKit                               0x342032b9 _UIApplicationMain + 1121
22  Tastemade                           0x00025047 main (main.m:12)

Image loading problem with ImageIO error

Hi,

I have AsyncImageView in scrollview. I am displaying images from web. Some time its give below error

ImageIO: PNG invalid PNG file: iDOT doesn't point to valid IDAT chunk

and doesnt load the image. Then if I go to another view and come back it displays the image.

Any suggestions ?

Memory Warnings & Crash

Thanks for amazing class,, its really awesome for lazy loading issues.
but i am facing memory warnings when i download more than 30 images and then its crashes...

 for(int i =0; i<[self.imageArray count];i++)
    {
   // self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake((320*(i)+7), 10, 306, 300)];

    NSString *imageURL = [[self.imageArray objectAtIndex:i]valueForKey:@"image_name"];

    NSURL *url = [NSURL URLWithString:imageURL];
          newPageView = [[AsyncImageView alloc] init];


    newPageView.imageURL=url;
    //   [newPageView loadImageFromURL:url withName:@"" andType:@"jpg"];
    newPageView.contentMode = UIViewContentModeScaleToFill;
    newPageView.frame = CGRectMake((320*(i)+7), 10, 306, 300);
    [newPageView setUserInteractionEnabled:YES];
       [self.scrollView addSubview:newPageView];

}

i am using scrollView to display multiple images horizontally with paging enabled.

AsyncImageLoader does not post notification when image is in cache

When loading an image (eg. via imageView.imageURL) and it's already in the cache, the AsyncImageLoader will simply return the image without posting the AsyncImageLoadDidFinish notification.

This is inconsistent with regards to loadImageWithURL which calls success regardless of the image being in the cache.

Perhaps either:

  • Update the documentation to reflect this behaviour
  • Update the code to consistently post notifications

Thanks.

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.