Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing back indexpath row to parent view
    text
    copied!<p>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. </p> <p>The code for child view is: </p> <pre><code> - (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 </code></pre> <p>ret view (DiarioA.h)</p> <pre><code>@property (nonatomic, assign) int rowTipo; </code></pre> <p>PArent view (Diario.m)</p> <pre><code>@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; } </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload