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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:33:58+00:00 2026-06-07T02:33:58+00:00

I have a TableView which has 2 sections and the 2nd section is only

  • 0

I have a TableView which has 2 sections and the 2nd section is only shown when the 3rd row in the first section is selected. Only the first section has images. Everything is working fine. The 3rd row in the 2nd section shows a TextField and a button when selected and you can save a date in there via pressing the finish button. Works also fine. You can select that row and go to other rows and everything is normal. If though, you tap into the TextField and don’t save the input or don’t write anything, then it bugs.
It will reload the table with images at random rows it seems.
I thought it’s the keyboard which pops up, so I tried to manually dismiss it. Bug is still there.
I am really curious why this happens, so I am hoping for help! Thanks in advance!!

My cellForRowAtIndexPath:

- (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];
    }

    // Configure the cell...

    BOOL tooltipValue = [[NSUserDefaults standardUserDefaults] boolForKey:@"tooltipSetting"];
    BOOL compactSettingValue = [[NSUserDefaults standardUserDefaults] boolForKey:@"compactModeSetting"];

   NSDictionary *dictionary = [self.settingsArray objectAtIndex:indexPath.section];
   NSArray *array = [dictionary objectForKey:@"Items"];
   NSString *cellValue = [array objectAtIndex:indexPath.row];
   cell.textLabel.text = cellValue;

   if (indexPath.section == 0 && self.iconSetCount < 3) {
        NSDictionary *imagedictionary = [self.imagesArray objectAtIndex:indexPath.section];
        UIImage *cellImage = [[imagedictionary objectForKey:@"images"] objectAtIndex:indexPath.row];
        cell.imageView.image = cellImage;
        self.iconSetCount++;
        NSLog(@"%d",self.iconSetCount);
    }


    if (indexPath.section == 0){
        if (indexPath.row == 0) {
            if (tooltipValue){
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            } else {
                cell.accessoryType = UITableViewCellAccessoryNone;
            }

        }
        if (indexPath.row == 1) {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
        if (indexPath.row == 2) {
            if (!compactSettingValue){
                cell.accessoryType = UITableViewCellAccessoryNone;
            } else {
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            }
        }
    } else if (indexPath.section == 1){
            // if the sellected row is the one with a custom date 
            if (indexPath.row == 2 && indexPath.row == isSelected) {
                // if an archive exists for the custom date then get the data from the archive
                if ([[NSFileManager defaultManager] fileExistsAtPath:[self getDocumentPathForCustomDate]]) {
                    NSString *customDate = [NSKeyedUnarchiver unarchiveObjectWithFile:[self getDocumentPathForCustomDate]];
                    cell.textLabel.text = customDate;
                } else{
                    //show a label with a done button where you can type in your custom date and save it
                    if (self.textField == nil) {
                        self.textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, 200, 35)];
                        self.textField.backgroundColor = [UIColor whiteColor];
                        self.textField.textColor = [UIColor blackColor];
                        self.textField.font = [UIFont systemFontOfSize:16.0];
                        self.textField.borderStyle = UITextBorderStyleRoundedRect;
                    }

                    if (self.button == nil) {
                        self.button =[UIButton buttonWithType:UIButtonTypeRoundedRect];
                        self.button.frame = CGRectMake(210, 5, 50, 35);
                        [self.button setTitle:NSLocalizedString(@"done", @"") forState:UIControlStateNormal];
                        [self.button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
                    }

                [cell.contentView addSubview: self.textField];
                [cell.contentView addSubview: self.button];

                }
            }
            if ((indexPath.row == self.isSelected)){
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            }else{
                cell.accessoryType = UITableViewCellAccessoryNone;
            }
        }
    return cell;

}

My didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    // Navigation logic may go here. Create and push another view controller.
    /*
    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"Nib name" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */

    BOOL tooltipValue = [[NSUserDefaults standardUserDefaults] boolForKey:@"tooltipSetting"];
    BOOL compactSettingValue = [[NSUserDefaults standardUserDefaults] boolForKey:@"compactModeSetting"];

    if (indexPath.section == 0) {
        //tooltips
        if (indexPath.row == 0) {
            if (!tooltipValue){
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"tooltipSetting"];
            } else {
                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"tooltipSetting"];
            }
            [self.tableView reloadData];
        }
        //go to Set your Signature Extra
        if (indexPath.row == 1) {
            AdditionalSignature *additionalSigi = [[AdditionalSignature alloc] initWithNibName:@"additionalSignature" bundle:nil];
            [self.navigationController pushViewController:additionalSigi animated:YES];
            [additionalSigi release];
        }

        //compact version
        if (indexPath.row == 2) {
            if (!compactSettingValue){
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"compactModeSetting"];                
            } else {
                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"compactModeSetting"];
            }      
            [self.tableView reloadData];
        }
    }
    // if in optional compactmode settings
    if (indexPath.section == 1){
        // and "none" is selected remove first the custom date
        if (indexPath.row == 0) {
            [self removeCustomDateArchive];

            //then change the userdefault for this setting
            if (![self isOptionNoDate]) {
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"dateSetting"];
            }else{
                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"dateSetting"];
            }
        }
        if ( indexPath.row == 1) {
            [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"dateSetting"];
            [self removeCustomDateArchive];
        }
        if (indexPath.row == 2) {
            [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"dateSetting"];

        }
        self.isSelected = indexPath.row;
        [self.tableView reloadData];
    }
}
  • 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-07T02:33:59+00:00Added an answer on June 7, 2026 at 2:33 am

    The cell identifier is abused here. Removing the cell identifier would be the quickest solution here, reallocating the cells every time.
    Rewriting the code to include the cell identifier would make it more robust.

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

Sidebar

Related Questions

I have a tableview, which has many sections. each section has just one cell.
I have a tableview with 2 sections. Section 1 has 1 row Section 2
I have a UITableViewController which has two sections. The first section shows a single
I have a tableview which each row has 4 images. I have implemented a
I have a UITableView With Two Sections. First section has one row and the
I have a simple UITableView with two sections. Each section has a header which
I have a tableView which has cells with phone numbers. The app is not
I have a dynamic tableview which has a prototype cell with a button that,
I am developing and tableView in which in each row I have to display
I have a tableview cell in a view which has some text in it,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.