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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:20:37+00:00 2026-05-26T07:20:37+00:00

On the WWDC 11 video ‘session 125 – UITableCiew Changes, Tips, Tricks’ at 24:30+

  • 0

On the WWDC 11 video ‘session 125 – UITableCiew Changes, Tips, Tricks’ at 24:30+ Mr Luke Hiesterman is giving a demo which adds a cell to the table view when a cell is selected.

Screenshot from the video

I want to add that functionality to my IOS application, but I can’t figure out how to make it.

Some code is not shown in the demo-video. And there is no downloadable source of the demo.

Can anyone help me out?

EDIT:

I can add a new row below the selected row but it is an other custom cell.

(I have a list of contracts which you can accept)

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ((indexPath.row >= [_contracts count]) ? 40 : 60);
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_contracts count] + ((_addedRow) ? 1 : 0);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *reuseID = @"contract_cell";

    ContractTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];

    if(!cell)
    {
        // Load the top-level objects from the custom cell XIB.
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ContractTableViewCell" owner:self options:nil];
        // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
        cell = [topLevelObjects objectAtIndex:0];
        [cell setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"contract_cell.png"]]];
    }

    NSLog(@"row?: %d", indexPath.row);
    //I thought this would work... not.
    if((indexPath.row >= [_contracts count]))
    {
        [cell.label setText:@"new"];
    }
    else
    {
        Contract *contract = [_contracts objectAtIndex:indexPath.row];

        [cell.label setText:@"test"];
    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(!_addedRow)
    {
        _addedRow = YES;

        [tableView deselectRowAtIndexPath:indexPath animated:NO];

        [_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section]] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section];
}

For example I press the first row. A row is added below the first one. But now the cellForRowAtIndexPath.. is called for row 2 (needs to be the new custom)

how can I check if it is a new one?

  • 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-26T07:20:37+00:00Added an answer on May 26, 2026 at 7:20 am

    You need to remember which of your rows is selected to show the added row at the correct index. Currently you’re always assuming that the added row is the very last one because you’re configuring it in tableView:cellForRowAtIndexPath: only if the index is bigger than your number of contracts.

    Say you have five contracts and the third one is selected. if((indexPath.row >= [_contracts count])) is only true for the last row but actually want this condition to be true for the fourth row, so it should be if (indexPath.row == selectedRowIndex + 1) (you need to store the selected row index in some instance variable).

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

Sidebar

Related Questions

In the WWDC video Session 309 - Introducing Interface Builder Storyboarding the speaker adds
I saw a WWDC 2010 video about NSFileProtectionComplete and protecting app's data. Are there
I downloaded the latest video capture samples from WWDC 2010 and am trying to
So, I was looking at some WWDC session videos again and the speaker told
I have seen the WWDC-104 video showing UIScrollView for photos. I have downloaded the
I was watching Advance Text Handling for iPhone OS video from WWDC. I really
I'm studdying the WWDC session #104 for mastering UIScrollViews . I need to create
After watching the WWDC video on the accelerate framework, I saw that it had
I watched Apple's WWDC 2010 video on Advanced Memory Analysis with Instruments and from
I was watching the WWDC ARC introduction video and I saw something I've never

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.