I implement the presentation of a grouped table in my application, where the user can select a row from another section of the table.
I want to hide (delete) a specific section (including the title) depending on the row selection of the first section.
i.e.
the heading of the first sections is “Do you have a car?”, the answer will be YES or NO in the row selection. if the user selects NO, the second and third sections from the grouped table should hide (delete).
to select a radio in a grouped table, I implement this
I also refer to this one , but do not fill in everything that I need.
Please, help.
Edit
TableViewDelegates
myArray is my data source. myArrayAnswerCount contains the number of rows in the section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [myArray count]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { for (int i = 0; i<[myArray count]; i++) { if (section==i) { return [[myArray objectAtIndex:i] title]; } } } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { for (int i = 0; i<[myArray count]; i++) { if (section==i) { return [[myArrayAnswerCount objectAtIndex:i] intValue]; } } }
this is the code for how I delete the section from the table, myIndexPath is the NSIndexPath variable that points to the selected section.
[table beginUpdates]; [myArray removeObjectAtIndex:myIndexPath.section]; [table deleteSections:[NSIndexSet indexSetWithIndex:myIndexPath.section] withRowAnimation:YES]; [table endUpdates];
source share