I\'m quite new to xcode, and I am trying to develop a sample app that is basically an embedded tableview which has many levels. I have a plist which stores the cells of each
THE MAIN ISSUE IS HERE, you were creating a blank DrillDownViewController, not reusing the one from storyboards, see comments in code below
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"segue1"])
{
[segue.destinationViewController setItemName:(NSString*)sender];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Check the dictionary to see what cell was clicked
NSDictionary *dict = [self.tableDataSource objectAtIndex:indexPath.row];
NSString *titleName = [dict objectForKey:@"Title"];
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
NSArray *children = [dictionary objectForKey:@"Children"];
if([children count] == 0)
{
[self performSegueWithIdentifier:@"segue1" sender:titleName];
}
else{
//Prepare to tableview.
//THE MAIN ISSUE IS HERE, you were creating a blank DrillDownViewController, not reusing the one from storyboards so it did not have a segue at all defined. instead do this:
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
DrillDownViewController *rvController = [sb instantiateViewControllerWithIdentifier:@"DDVC"];
//Increment the Current View
rvController.CurrentLevel += 1;
//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = children;
}
}