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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:31:10+00:00 2026-05-25T11:31:10+00:00

I have a UITableViewController with an Edit button. When this is clicked, the user

  • 0

I have a UITableViewController with an Edit button. When this is clicked, the user can delete or add rows to the UITableView. Deleting rows works fine. But when I want to add a new row, I get a short animation of an empty cell coming from the left and when the animation is over, the table view looks exactly as it looked before the method was called. When I add a new cell, I add a new object to the data array that feeds my table view and then add the cell. That data array gets updated. So if I call [tableView reloadData] after I have added the new cell, I get to see the new cell but without any animation. And I really would like to have the animation as well.

I have a working example of the same thing. I realized that after tableView:commitEditingStyle:forRowAtIndexPath: gets called, the table view’s data source method tableView:cellForRowAtIndexPath: gets automatically called. In my case, it doesn’t. I guess that’s the reason why I’m not seeing the new cell. Any ideas why this is happening?

This is my `tableView:commitEditingStyle:forRowAtIndexPath:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    {
        // Delete the row from the data source
        [self.tableData removeObjectAtIndex:[indexPath row]];

        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:self.tableData forKey:self.key];
        [defaults synchronize];

        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) 
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
        UITextField *textField = (UITextField *)[[cell contentView] viewWithTag:kTextFieldTag];
        NSString *textFieldText = [textField text];
        if (textFieldText != nil) 
        {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
            NSString *string = [[NSString alloc] initWithString:textFieldText];
            [self.tableData addObject:string];
            [string release];

            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults setObject:self.tableData forKey:self.key];
            [defaults synchronize];

            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];   

            // If reloadData is being called, the new cell is displayed but without the animation
            // [tableView reloadData]; 
        } 
        else
        {
            // Display alert view
            // Code for displaying an AlertView
        }
    }   
}
  • 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-25T11:31:11+00:00Added an answer on May 25, 2026 at 11:31 am

    Try wrapping your insert call with [tableView beginUpdates] [tableView endUpdates]. From the docs:

    If you do not make the insertion, deletion, and selection calls
    inside this block, table attributes such as row count might become
    invalid.

    [tableView beginUpdates];
    [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
    [tableView endUpdates];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableViewController where the user should be able to edit the items.
I have made a table containing an array editable (you can delete rows) by
I have a UITableViewController that works in both portrait and landscape. From this controller
I have a UITableViewController (MyViewController.xib). This is showing 3 rows with their title. I
If I create a UITableViewController - drilling down works as expected. If a user
I have this code to set the background image of the UITableViewController: self.tableView.backgroundColor =
I have a UITableViewController that is fed by a NSFetchedResultsController . Everything worked fine,
Hi i have a working UITableViewController and UITableView with custom cells but i want
I have a .xib with a controller, a UITableViewController . It contains a UITableView
I have a typical UITableViewController set of views. On all views is a button,

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.