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 9155301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:34:02+00:00 2026-06-17T12:34:02+00:00

I have successfully implemented lazy-loading of images in my app using the example provided

  • 0

I have successfully implemented lazy-loading of images in my app using the example provided by apple here. The thing is that, I want the image to load as I am scrolling, but the image loads into the cell only when I finish dragging (Release my finger from the screen. Until then the cell remains empty). I have modified the code as follows:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    //NSLog(@"cell for row at indexpath, size - %f, current - %d", flowTable.contentSize.height, self.current);

    NSString *CellIdentifier = @"FlowCell";

    MyFlowCell *cell = (MyFlowCell *)[self.flowTable dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FlowCell" owner:nil options:nil];
       // cell = [nib objectAtIndex:0];

        for(id currentObject in nib)

        {

        if([currentObject isKindOfClass:[MyFlowCell class]])

        {
            cell = (MyFlowCell *)currentObject;

            break;
        }
        }
    }

    ImageDetails *rowItem = [self.imageData objectAtIndex:indexPath.row];

    if (!rowItem.mainImage)
    {  
       // if (self.flowTable.dragging == NO && self.flowTable.decelerating == NO)
       // {

            [self startIconDownload:rowItem forIndexPath:indexPath];

        //}

        cell.mainImage.backgroundColor = [UIColor grayColor];

    }
    else
    {

            cell.mainImage.image = rowItem.mainImage;

    }
    }


    return cell;
}


- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (!decelerate)
    {
      //  [self loadImagesForOnscreenRows];
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //[self loadImagesForOnscreenRows];
}

Moreover, I found out that in my ImageDownloader class, the NSURLConnection doesn’t even receive the response until I release my finger from the screen. I have been trying to find out why this is happening, but I haven’t been successful so far. Please tell me if I’ve been missing something.

  • 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-17T12:34:03+00:00Added an answer on June 17, 2026 at 12:34 pm

    You can achieve lazy loading in your tableview by following these steps :

    In your Class.h, put:

    NSMutableDictionary *Dict_name;
    BOOL isDragging_msg, isDecliring_msg;
    

    Now In Class.m file, put this code in view did load:

    Dict_name = [[NSMutableDictionary alloc] init];
    

    In cellForRowAtIndexPath:

    if ([dicImages_msg valueForKey:[[msg_array objectAtIndex:indexPath.row] valueForKey:@"image name or image link"]]) { 
        cell.image_profile.image=[dicImages_msg valueForKey:[[msg_array objectAtIndex:indexPath.row] valueForKey:@"image name or image link"]];
    }
    else
    {
        if (!isDragging_msg && !isDecliring_msg)
        {
            [dicImages_msg setObject:[UIImage imageNamed:@"Placeholder.png"] forKey:[[msg_array objectAtIndex:indexPath.row] valueForKey:@"image name or image link"]];
            [self performSelectorInBackground:@selector(downloadImage_3:) withObject:indexPath];
        }
        else
        {
            cell.image_profile.image=[UIImage imageNamed:@"Placeholder.png"];
        }
    }
    

    And for the download image the function is:

    -(void)downloadImage_3:(NSIndexPath *)path{
        NSAutoreleasePool *pl = [[NSAutoreleasePool alloc] init];
    
        NSString *str=[here Your image link for download];
    
        UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:str]]]; 
    
        [dicImages_msg setObject:img forKey:[[msg_array objectAtIndex:path.row] valueForKey:@"image name or image link same as cell for row"]];
    
        [tableview performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
    
        [pl release];
    }
    

    And at last put these methods in your class:

    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
        isDragging_msg = FALSE;     
        [tableview reloadData];
    }
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
        isDecliring_msg = FALSE;
        [tableview reloadData]; 
    }
    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
        isDragging_msg = TRUE;
    }
    - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
        isDecliring_msg = TRUE; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully implemented lazy loading using the class UIImageView+WebCache.h . Is there any
I have successfully implemented printing and print preview for my app using the PrintDocument,
I have successfully implemented authentication using GTM OAuth 2 library. But now I want
I have successfully implemented a cel shader using glsl. But my problem is about
I have successfully implemented a network application in visual CLR project using boost.asio. but
I have successfully implemented slider to my Cocos2D project using this resource . The
I have successfully implemented Remember Me functionality in my application. Only I want to
I have successfully implemented Autocomplete field from database using sfWidgetFormJQueryAutocompleter but i cannot a
I have successfully implemented embedded vimeo videos into my app, however i would like
I have successfully implemented this method of using the Win32 API to set the

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.