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

  • Home
  • SEARCH
  • 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 8145125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:34:18+00:00 2026-06-06T13:34:18+00:00

I have an UITableView and it has 18 sections, in each section there is

  • 0

I have an UITableView and it has 18 sections, in each section there is 1 title header and 1 cell. In each cell, there will be a horizontal UIScrollView with more than a few images.

Problem is… I can load the images and the cells correctly, but when the image quantity increases and when the cell get scrolled to top, there are images from different cell popping up in other cells… and all the render and images are all wrong… images supposed to be in section 3 or 4 appears in section 1….etc.

The datasource is loaded from JSON, and the JSON is right. Everything works perfectly when images is not much and with only 5-8 sections. So, it leads me to believe it’s the reuse of the UITableViewCell which generates this problem.

Can somebody give me a hand on this… thanks.. below is the code of the UITableViewCell

// Customize the appearance of table view cells.

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

UITableViewCell *cell = nil;

// add a placeholder cell while waiting on table data
if ([self.datasource count] == 0 && indexPath.section == 0 && indexPath.row == 0)
{   
    UILabel *Fetch;
    static NSString *infoCell = @"infoCell";
    cell = [tableView dequeueReusableCellWithIdentifier:infoCell];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                       reuseIdentifier:infoCell] autorelease];   
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        CellFetch = [[[UILabel alloc] initWithFrame:CGRectMake(15.0, 120.0, 280.0, 80.0)] autorelease];
        CellFetch.tag = FETCH_TAG;
        CellFetch.font = [UIFont boldSystemFontOfSize:16.0];
        CellFetch.textColor = [UIColor grayColor];
        CellFetch.shadowColor = [UIColor whiteColor];
        CellFetch.shadowOffset = CGSizeMake(0, -0.5);
        CellFetch.textAlignment = UITextAlignmentCenter;
        [cell.contentView addSubview:CellFetch];
    } else {
        CellFetch = (UILabel *)[cell.contentView viewWithTag:FETCH_TAG];
    }
    Fetch.text = fetchStatus;
    return cell;
} else {
UIScrollView *imgScroll;
static NSString *imgCell = @"imgCell";
cell = [tableView dequeueReusableCellWithIdentifier:imgCell];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:imgCell] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    imgScroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 108.0)]autorelease];
    imgScroll.tag = SCROLLVIEW_TAG;
    imgScroll.showsVerticalScrollIndicator = NO;
    imgScroll.showsHorizontalScrollIndicator = NO;
} else {
    imgScroll = (UIScrollView *)[cell.contentView viewWithTag:SCROLLVIEW_TAG];
}
    NSArray *sorted = [[self.datasource allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
    //NSArray *allDistrict = [self.datasource allValues];
    NSString *key = [sorted objectAtIndex:indexPath.section];
    NSArray *img = [self.datasource valueForKey:key];

    int column = 0;
    int space = 10;
    int width = 80;
    int x = space+5.0;
    for (NSUInteger i=0; i < img.count; i++) {
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        NSDictionary *Info = [img objectAtIndex:i];
        NSString *iconURL = [NSString stringWithFormat:@"%@",[Info objectForKey:@"ImgURL"]];
        button.frame = CGRectMake(x , 4, 80, 80);
        [button setImageWithURL:[NSURL URLWithString:iconURL] placeholderImage:[UIImage imageNamed:@"pholder"]];
        NSString *imgID = [Info objectForKey:@"ImgID"];
        int k = [imgID intValue];
        button.tag = k; 
        [button addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [imgScroll addSubview:button];


        x+=space+width;
        column++;
    }

    [imgScroll setContentSize:CGSizeMake(column*90+10, 108)];

    [cell.contentView addSubview:imgScroll];
}
// Configure the cell...
return cell;

}

  • 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-06T13:34:19+00:00Added an answer on June 6, 2026 at 1:34 pm

    Try making your cell identifier unique for each section so that way they won’t get reused across sections:

      cell = [tableView dequeueReusableCellWithIdentifier:@"section1cell"];
    
      cell = [tableView dequeueReusableCellWithIdentifier:@"section2cell"];
    

    I’ve seen that problem where cells in certain sections do not have an image, but in other sections they do. So when it reuses the cell, unless you specifically set the image property to nil… you could get an imaged that was previously laoded.

    UPDATE:

    Here is what I’m talking about in regards to the section number

    - (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {    
        NSString *section = [NSString stringWithFormat:@"section%@cell", indexPath.section];
    
        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:section];
    
        // some configuration
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple UITableView with two sections. Each section has a header which
I have a UITableView with multiple sections. Each section has a section header (a
I have a UITableView with two sections: free and paid. Each section has a
I have a UITableView with two sections. Each section has a few UITableViewCells .
I have a UITableView that has five sections. Just as the title describes cellForRowAtIndexPath
I have a UITableView With Two Sections. First section has one row and the
I have a custom UITableView cell that has a UIImageView sized to the width
I have a UITableView with two custom cells and each of them has a
I have UITableView with very large cells with lots of content (more than one
I have a UITableView that is grouped into sections and has a number of

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.