Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:38:03+00:00 2026-06-13T01:38:03+00:00

I am trying to implement UICollectionView and show images. I am using SDWebimage which

  • 0

I am trying to implement UICollectionView and show images. I am using SDWebimage which works perfectly in tableviewcells but when i tried to use it in UICollectionviewCell it doesn’t stop and remove activityindicator. It does place the placeholder image if there is no downloaded image. I am not sure what is the difference between tableviewcell and collectionviewcell that might cause this problem.

Here is the code:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"personImageCell";

    PersonCollectionViewCell *cell = (PersonCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
    NSString *imgURL=[person.imageurl stringByAppendingString:@"?maxheight=300&maxwidth=400"];

    UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    activityIndicator.hidesWhenStopped = YES;
    activityIndicator.hidden = NO;
    [activityIndicator startAnimating];
    activityIndicator.center = CGPointMake(cell.ivPersonImage.frame.size.width /2, cell.ivPersonImage.frame.size.height/2);
    [cell.ivPersonImage setImageWithURL:[NSURL URLWithString:imgURL] placeholderImage:nil options:SDWebImageProgressiveDownload success:^(UIImage *image, BOOL cached){
        [activityIndicator stopAnimating];[activityIndicator removeFromSuperview];
        NSLog(@"activity indicator should be removed");
    }failure:^(NSError *error){
        [activityIndicator stopAnimating];[activityIndicator removeFromSuperview];
        cell.ivPersonImage.image = [UIImage imageNamed:@"placeholder.png"];
    }];


    [cell.ivPersonImage addSubview:activityIndicator];
    return cell;
}

UPDATE:

When i do NSLog(@"activity indicator should be removed %@,activityIndicator);

I get this output:

 activity indicator should be removed <UIActivityIndicatorView: 0xa520ab0; frame = (65 90; 20 20); hidden = YES; layer = <CALayer: 0xa520b60>> 

It shows that UIActivityindicator is hidden but it is still showing on top of the image

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:38:04+00:00Added an answer on June 13, 2026 at 1:38 am

    It seems that you are reusing cell so there are more then one UIActivityIndicatorViews.

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"personImageCell";
    
        PersonCollectionViewCell *cell = (PersonCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
        Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
        NSString *imgURL=[person.imageurl stringByAppendingString:@"?maxheight=300&maxwidth=400"];
    
        UIActivityIndicatorView *activityIndicator = [cell.ivPersonImage viewWithTag:10];
        if (activityIndicator) [activityIndicator removeFromSuperview];
        activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        activityIndicator.hidesWhenStopped = YES;
        activityIndicator.hidden = NO;
        [activityIndicator startAnimating];
        activityIndicator.center = cell.ivPersonImage.center;
        activityIndicator.tag = 10;
    
        [cell.ivPersonImage addSubview:activityIndicator];
        [cell.ivPersonImage setImageWithURL:[NSURL URLWithString:imgURL] placeholderImage:nil options:SDWebImageProgressiveDownload success:^(UIImage *image, BOOL cached){
            [activityIndicator stopAnimating];[activityIndicator removeFromSuperview];
            NSLog(@"activity indicator should be removed");
        }failure:^(NSError *error){
            [activityIndicator stopAnimating];[activityIndicator removeFromSuperview];
            cell.ivPersonImage.image = [UIImage imageNamed:@"placeholder.png"];
        }];
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement search with Sunspot Gem wich is using Solr.Fulltext search works fine
Trying to implement Piwik using REST API over http but need a little help.
I am currently trying to implement the UITableView reordering behavior using UICollectionView. Let's call
Trying to implement something similar to qtip, but using a table that compares the
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I'm trying implement a bracket in my program (using C#/.NET MVC) and I am
Trying to implement AVAudioplayer and get some metering data of the played music, but
While trying to implement a scene where item sizes do not change but distances
I'm trying implement a way to recursively template using jsRender. The issue is, my
Trying to implement the following structure from c to use NSArray in objective-c: In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.