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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:56:26+00:00 2026-05-23T17:56:26+00:00

I am stuck in a problem, I have a uitableview with rows let say

  • 0

I am stuck in a problem, I have a uitableview with rows let say 5.
If a user selects one row then a new row exactly beneath the tapped row should be created/inserted with an animation (as we have seen with sections hiding/unhiding) and upon tap of the newly inserted row it should be deleted.

I have given a try but it says


Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid  
update: invalid number of rows in section 0.  The number of rows contained in an existing section 
after the update (6) must be equal to the number of rows contained in that section before the update 
(5), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted).'

so what should be the other way to achieve this functionality ?
Thanks in advance.

  • 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-23T17:56:26+00:00Added an answer on May 23, 2026 at 5:56 pm
    
    - (NSInteger)numberOfRowsInSection:(NSInteger)section {
        switch (section) {
            case 0:
                return numberOfRows;
        }
        return 0;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        numberOfRows ++;
        [tableView deselectRowAtIndexPath:indexPath animated:NO];
        NSMutableArray*  tempArray = [[NSMutableArray alloc] init];
            [tempArray addObject:[NSIndexPath indexPathForRow:indexPath.row +1  inSection:indexPath.section]];
        [tableView beginUpdates];
        [tableView insertRowsAtIndexPaths:tempArray withRowAnimation:UITableViewRowAnimationRight];
        [tableView endUpdates]; 
        [tempArray release];
    
    }
    
    
    
    

    I was making 2 mistakes
    1) I wasnot using [tableView beginUpdates] and obviously [tableView endUpdates] after updation
    2) The method to calculate the indexpath for a newRow was ambigious.

    Thankyou very much pratikshabhisikar and Max Howell for putting your time and efforts in.

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

Sidebar

Related Questions

I'm new to wicket and stuck with the following problem: I have a table
I am working on a problem and got stuck at a wall I have
I've been stuck on a little unix command line problem. I have a website
Hope to get solution to this problem. I have been stuck on it since
I am stuck with a programming problem: I have two Java projects, in my
Hello I have a problem with UITableView freeze, downloadItem below gets called when someone
This is by far the weirdest problem I've been stuck with. I have a
I have a UITableView that displays images associated with contacts in each row. In
I'm working on a project and I'm stuck with this problem: I have a
i have problem with mysql query and i'm stuck... I have post with many

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.