tags:

views:

26

answers:

1

I am pushing a bunch of views to my navigation controller but on some nav choices I do not want to add them to the long list but I want it to show up at the front of the stack and get rid of the rest.

here is the behavior I am using:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NavigationTestAppDelegate *appDelegate  = (NavigationTestAppDelegate *) [[UIApplication sharedApplication] delegate];

    UIViewController *targetController = nil;   

    switch (indexPath.row) {
        case 0:
            targetController = [[ClientListViewController alloc] init];
            targetController.title = @"Clients";
            break;
        case 1:

            break;
        case 2:
            targetController = [[MyInfoViewController alloc] init];
            targetController.title = @"My Information";
            break;
        default:
            break;
    }

    if ([targetController isKindOfClass:[ClientListViewController class]])
    {
        [[self navigationController] pushViewController:targetController animated:YES];
    } else {    
    if (targetController) 
        [[appDelegate.homeViewController navigationController] pushViewController:targetController animated:YES];

    if (appDelegate.popoverController)
        [appDelegate.popoverController dismissPopoverAnimated:YES]; 
    }

    [targetController release];
}

If my user clicks the MyInfoViewController I want that to be the only thing in the navigation controller stack and have it slide in.