I am kinda new in Xcode and now I am working on a Expandable/Collapsable UITableView. The basic idea is to create new sub dropdown cells when the first master cell is clicked and subcells can segue to a detail view. But I hope to segue to a detail view from those new sub cells. I found there are two options:
- Create a segue
- Create a pushviewcontroller.
I dragged a new view controller and defined its storyboard ID, and tried to programmatically create a segue to push the new detail view. but it is not working. Could anyone help me? Thanks.
//didSelectRowAtIndexPath
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//to change the button image when selecting a row.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIButton *arrowBtn = (UIButton*)[cell viewWithTag:10];
NSDictionary *dic=[self.itemsinTable objectAtIndex:indexPath.row];
if([dic valueForKey:@"list"])
{
NSArray *listarray=[dic valueForKey:@"list"];
BOOL isTableExpanded=NO;
for(NSDictionary *subitems in listarray )
{
NSInteger index=[self.itemsinTable indexOfObjectIdenticalTo:subitems];
isTableExpanded=(index>0 && index!=NSIntegerMax);
if(isTableExpanded) break;
}
if(isTableExpanded)
{
[self CollapseRows:listarray];
[arrowBtn setImage:[UIImage imageNamed:@"down_arrow.png"] forState:UIControlStateNormal];
}
else
{
NSUInteger count=indexPath.row+1;
NSMutableArray *arrCells=[NSMutableArray array];
for(NSDictionary *dInner in listarray )
{
[arrCells addObject:[NSIndexPath indexPathForRow:count inSection:0]];
[self.itemsinTable insertObject:dInner atIndex:count++];
}
[self.expandingtableView insertRowsAtIndexPaths:arrCells withRowAnimation:UITableViewRowAnimationTop];
[arrowBtn setImage:[UIImage imageNamed:@"up_arrow.png"] forState:UIControlStateNormal];
//This segue is not working...
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"detailvcontroller"];
[self.navigationController pushViewController:controller animated:YES];}}}