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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:14:48+00:00 2026-05-31T16:14:48+00:00

I have an iPhone app which has a Table View-based data input screen with

  • 0

I have an iPhone app which has a Table View-based data input screen with a toggle, which when on shows all rows in another section of the table.

Sometimes, when the app is first loaded, and usually when it has been fully deleted from the phone, the UITextFields from the original section of the table are displayed in addition to the new rows, as below (main table section is above)

enter image description here:

THe strangest thing about this is that this behaviour only occurs the first time this screen is displayed – it seems fine after that. Oh, and it only seems to occur on the phone, not the simulator.

Given the random nature of this, could it have something to do with other apps? I did have apps with similar namespaces running at the same time. The problem seemed to go away after I closed the apps down / deleted from phone.

I have included the code block that is run when the switch is changed below:

- (void)accountSwitchChanged {
[customerDetails saveField:@"addToAccount" WithBool:addToAccountSwitch.on];

NSArray *indexes = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:1], [NSIndexPath indexPathForRow:2 inSection:1], [NSIndexPath indexPathForRow:3 inSection:1],nil];

if (addToAccountSwitch.on)
    [detailsTable insertRowsAtIndexPaths:indexes withRowAnimation:UITableViewRowAnimationFade];
else
    [detailsTable deleteRowsAtIndexPaths:indexes withRowAnimation:UITableViewRowAnimationFade];
}

Any ideas?

–EDIT

cellForRowAtIndexPath code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// get rid of grey background for iPad app
[tableView setBackgroundView:nil];
UITableViewCell *cell = nil;
NSDictionary *cellData = [[dataSourceArray objectAtIndex: indexPath.section] objectAtIndex:indexPath.row];

id cellControl = [cellData objectForKey:kCellControlKey];

    static NSString *kCellControl = @"CellControl";
    cell = [tableView dequeueReusableCellWithIdentifier:kCellControl];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellControl] autorelease];
        cell.textLabel.textColor = [[[ConfigManager sharedInstance].skin valueForKey:@"tableCellHeadingTextColour"] toUIColor];
        cell.backgroundColor = [[[ConfigManager sharedInstance].skin valueForKey:@"tableCellBgColour"] toUIColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
    } else {
        // a cell is being recycled, remove the old control (if it contains one of our tagged edit fields)
        UIView *viewToCheck = nil;
        viewToCheck = [cell.contentView viewWithTag:kDetailsViewTag];
        if (!viewToCheck)
            [viewToCheck removeFromSuperview];
    }

    // if control is not a text field, make it a button
    if (![cellControl isKindOfClass:[UITextField class]])
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
    else
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

    cell.textLabel.text = [cellData objectForKey:kCellTitleKey];
    [cell.contentView addSubview:cellControl];

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-05-31T16:14:50+00:00Added an answer on May 31, 2026 at 4:14 pm

    Something to check and eliminate If it is only occurring the first time view is displayed, it’s always worth checking whether you are assuming the view is loaded before you are doing work on it. This doesn’t come up very often, but when it does it can be very hard to track down. To check whether this might be your issue, add a [viewController view] call just after you create the view for the first time. This forces the view to be loaded. If the issue goes away when you add this, you’ve tracked the source of the issue. And you can even leave the [viewController view] call in as a fix, or work through your code to allow for lazy instantiation.

    All this said, far more likely to be something funny in your tableView:cellForRowAtIndexPath: code. If you want good stack overflow, post all or relevant fragment of the that code (or the relevant code it calls).

    Follow up on posted code:

    (1) if (!viewToCheck) [viewToCheck removeFromSuperview] won’t do anything. It’ll only send a removeFromSuperview message when viewToCheck is nil and that won’t do anything. Not sure if this will be key issue, but it’s something to put right.

    (2) [cell.contentView addSubview:cellControl]; – this looks problematic – it’s usually best to only add subviews when you create the cell. You can hide or show in the main body of tableView:cellForRowAtIndexPath: – that would, I suspect, work for you here. With this code there’s a risk here that you’ll either add multiple subviews when you only want one or (which may be what’s going on here) that you end up not removing a subview when a cell is recycled. If the viewToCheck code is supposed to be removing the added cellControl then, as (1), it won’t do that just now because your if condition is wrong.

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

Sidebar

Related Questions

I have a MonoTouch iPhone app which has a UITableViewController as it's main view
I have an iPhone app which has a tabBarController as the root view controller
I'm working on a view-based iPhone app that has the following flow: search ->
I'm working on an table drill-down style iPhone app that has prepopulated data. I
I'm working on a iPhone app which has a pretty large UITableView with data
I have a content based, read-only iPhone app. Users can select favorite topics, which
I have an iPhone App which has one file (.h .m) for 2 nibs.
I develop an app for iPhone / iPod Touch which has to have access
For an iPhone app that has to have a bunch of data inserted before
I have an iphone app which has an NSURLConnection downloading a large video file.

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.