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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:48:59+00:00 2026-05-29T07:48:59+00:00

I have two UITableview. The first one shows 3 sections with 3 row each

  • 0

I have two UITableview. The first one shows 3 sections with 3 row each one, this is the default layout. When the user press line 2 section 0, the second view is showed to select a value. Once the value is selected, it returns to the first view, but this time, with a different layout. Depending on the value selected, the first view can only show one, two or three sections. I’m trying to achieve this behavior passing the indexpath from the child view to its parent and dynamically change the number of sections. I get the number of row selected in child view, but once it is passed to the parent view, the row numbers gets zero.

The code for child view is:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
          [tableView deselectRowAtIndexPath:indexPath animated:YES];
          NSUInteger row = indexPath.row;
          //Create parent view instance to pass back indexpath as a integer
          DiarioA *plc = [[DiarioA alloc] init];
          NSInteger i1 = row; 
          plc.rowTipo = i1;
          [plc release];
          [self.navigationController popViewControllerAnimated:YES];
}
Pa

ret view (DiarioA.h)

@property (nonatomic, assign) int rowTipo;

PArent view (Diario.m)

@synthesize rowTipo;

- (void)viewWillAppear:(BOOL)animated{
       [self.tableView reloadData];
       //Check if rowTipo has value
       NSLog(@"RowTipo: %d",rowTipo);
  }

//Use rowTipo to dynamically adjust uitableview layout.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
      if (self.rowTipo==0) {
          return 3;
      }
      return self.rowTipo;
   }

Could you help me to indentify why I’m loosing the indexpath that is coming from the childview to parentview. Your help is greatly appreciated.

  • 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-29T07:48:59+00:00Added an answer on May 29, 2026 at 7:48 am

    DiarioA *plc = [[DiarioA alloc] init];
    you are creating a new object here and setting the plc.rowTipo = i1; changes the value of this object not the parent object.
    Either you pass your parent object to the child controller and then change its value like this.

    // child .h file
    
    DiarioA *plc;
    @property (nonatomic, assign) DiarioA *plc;
    
    //child .m file
    @synthesize plc;
    
    // code when you push your child controller
    ChildController *controller = [[ChildController allo] initWithNibName.....];
    controller.plc = self
    

    and

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
              [tableView deselectRowAtIndexPath:indexPath animated:YES];
              NSUInteger row = indexPath.row;
              plc.rowTipo = row;
              [self.navigationController popViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an instance of UITableView with two sections, the first with one row
I have a UITableView With Two Sections. First section has one row and the
In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have one problem with two sections in UITableview grouped style. First section having
I have a UITableView with two sections: free and paid. Each section has a
I have a UITableViewController which has two sections. The first section shows a single
I have a simple UITableView with two sections. Each section has a header which
I have a UITableView with two sections. Each section has a few UITableViewCells .
I have two views: the first one is a UITableView in plain style (created
I have a UITableView with custom UITableViewCells. The table has two sections, the first

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.