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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:44:02+00:00 2026-05-24T19:44:02+00:00

When i scroll down my UITableView, it starts showing me the same cells that

  • 0

When i scroll down my UITableView, it starts showing me the same cells that i’ve already seen, and scrolling around a bit continues to put cells in the wrong place.

Here’s the code i’m using. If anything additional is needed then let me know:

.h

@interface HomeViewController : UITableViewController {


    int numberOfRows;

    NSArray *allVaults;

}

@property (nonatomic, assign) int numberOfRows;
@property (nonatomic, retain) NSArray *allVaults;

@end

.m

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
NSString *vaultsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Vaults"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    self.allVaults = [fileManager contentsOfDirectoryAtPath:vaultsPath error:nil];

numberOfRows = [self.allVaults count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return numberOfRows;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


        NSString *vaultsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Vaults"];

        NSString *dictionaryPath = [NSString stringWithFormat:@"%@/%@",
                                    vaultsPath,
                                    [self.allVaults objectAtIndex:indexPath.row]];

    NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:dictionaryPath];

        cell.backgroundView = [AHCellCreation backgroundView];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.selectedBackgroundView = [AHCellCreation selectedBackgroundView];
    cell = [AHCellCreation createCellWithDictionary:dictionary Cell:cell];
    }
    return cell;
}

Any help is appreciated!

EDIT 1: Image to show what happens when i move most code outside the (cell == nil) if statement:

Before: enter image description here

After: enter image description here

EDIT 2:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 82;
}
  • 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-24T19:44:03+00:00Added an answer on May 24, 2026 at 7:44 pm

    It looks as if you are only setting the cell content when the you’re getting a nil back from dequeueReusableCellWithIdentifier. You need to set the cell contents every time, not just when you need to create a new cell.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"Cell";
    
        AHCell *cell = (AHCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
            // create a new cell if there isn't one available to recycle
            // cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            cell = [AHCell blankCell];
    
        }
    
        // set the contents of the cell (whether it's a new one OR a recycled one)
        NSString *vaultsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Vaults"];
    
        NSString *dictionaryPath = [NSString stringWithFormat:@"%@/%@",
                                    vaultsPath,
                                    [self.allVaults objectAtIndex:indexPath.row]];
    
        NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:dictionaryPath];
    
        cell.backgroundView = [AHCellCreation backgroundView];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.selectedBackgroundView = [AHCellCreation selectedBackgroundView];
        // cell = [AHCellCreation createCellWithDictionary:dictionary Cell:cell];
        [cell populateAHCellWithDictionary: dictionary];
        return cell;
        }
    

    Update updated code to address second issue. Rework AHCell so that the class method, e.g. blankCell returns a new cell with the subviews set up and the instance method, e.g. populateAHCellWithDictionary: sets the content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I read that there is a software called WinCalibra (scroll a bit down)
UPDATED : Scroll down for updated. I have a UITableView which cells contain few
I have a UITableView that I want to scroll down and up without touching
I've seen this weird behavior on several sites recently: I scroll down a page
I use UITableView. If I change text in text field and then scroll down
I have a UITableView that their cells are UITableViews (the root tableView is rotated
(Scroll down to bottom of post to find solution.) Got a asp.net page which
Is it possible to scroll down the left and right parts of a vertically
If you scroll down to the section 'Writing to Files and URLs' at this
When you scroll down to the bottom of http://www.dzone.com/links/ it automatically loads more links.

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.