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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:16:26+00:00 2026-05-23T04:16:26+00:00

I am loading some images in my table view with a click of a

  • 0

I am loading some images in my table view with a click of a button.The images are loaded fine and in desired positions.But when i scroll the table view then images seems to change .Let me elaborate only 2 rows are visible in my table view initially ,and lets assume the images are there in both rows and 4 images in a row.Now when i scroll the table view downwards or upwards the row which is scrolled above or below the table view frame will show the new image in its image view.And everytime when i scroll the images keep on changing.What could be the reason.I am scratching my head with this.Please help.I am posting a part of my code:-

-(UITableViewCell*)tableView(UITableView*)
ableViewcellForRowAtIndexPath(NSIndexPath*)indexPath {

    UITableViewCell *cell = nil;
    static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
    cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
    if (cell == nil) {
        cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:AutoCompleteRowIdentifier] autorelease];

    }
    UIImageView * imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(25, 4, 80, 80)] autorelease];
    UIImageView * imageView2 = [[[UIImageView alloc] initWithFrame:CGRectMake(115,4,80, 80)] autorelease];
    UIImageView * imageView3 = [[[UIImageView alloc] initWithFrame:CGRectMake(205,4, 80, 80)] autorelease];
    UIImageView * imageView4 = [[[UIImageView alloc] initWithFrame:CGRectMake(295,4, 80, 80)] autorelease];
    imageView1.tag = 1;
    imageView2.tag = 2;
    imageView3.tag = 3;
    imageView4.tag = 4;
    [cell.contentView addSubview:imageView1];
    [cell.contentView addSubview:imageView2];
    [cell.contentView addSubview:imageView3];
    [cell.contentView addSubview:imageView4];

     UIImageView * imageView;
    for ( int i = 1; i <= 4; i++ ) {
        imageView = (UIImageView *)[cell.contentView viewWithTag:i];
        imageView.image = nil;

    }

    int photosInRow;
    if ( (indexPath.row < [tableView numberOfRowsInSection:indexPath.section] - 1) ||
        (count % 4 == 0) ) {
        photosInRow = 4;
    } else {
        photosInRow = count % 4;
    }

    for ( int i = 1; i <= photosInRow; i++ ) {
        imageView = (UIImageView *)[cell.contentView viewWithTag:i];

        [self setImage1:imageView];

    }

    return cell;
} 


-(void)setImage1:(UIImageView *)imageView
{

    UIImageView *imageView1=[[UIImageView alloc]init];

    imageView1=imageView;
    imageView1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", j]];

    j++;

}

Any help will be appreciated.

Thanks,
Christy

  • 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-05-23T04:16:27+00:00Added an answer on May 23, 2026 at 4:16 am

    Your setImage1: method should be modified to take in the photo index as j is not a proper way to track the current image as cellForRowAtIndexPath: may be called in any order.

    - (void)setImage1:(UIImageView *)imageView forPhotoIndex:(NSInteger)index {
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld.png", index]];
    }
    

    and minor modification in cellForRowAtIndexPath: would be,

    [..]
    for ( int i = 1; i <= photosInRow; i++ ) {
        imageView = (UIImageView *)[cell.contentView viewWithTag:i];
        [self setImage1:imageView forPhotoIndex:(indexPath.row * 4 + i - 1)];
    }
    [..]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing some performance problems loading about 60 images from a SQLite3 table with
Having some annoying issues with loading images into a BufferedImage (image in the example)
I am loading some text dynamically into a div, but have the problem that
I have a UITableView loading some tweets, all works nicely but when I populate
Apple just released some sample code on lazy loading images in a UITableView a
I have this script to load some images after page loading is complete I
In this block of code I am loading some images of dice, and trying
I am loading images using the JSON. But it makes app slow as it
give some idea about lazy loading,so that i can load more than 20 images
I am trying to create a options button above my scroll view that will

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.