iphone selecting a row to change view
- by Rob J
I have created the view Controllers and attached those to control their respective views. I can't figure out how to make the following code to go the right views though. (This is in the root view controller:)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
RunViewController *runViewController = [[RunViewController alloc] initWithNibName:@"RunView" bundle:[NSBundle mainBundle]];
CalcViewController *calcViewController = [[CalcViewController alloc] initWithNibName:@"CalcView" bundle:[NSBundle mainBundle]];
PushViewController *pushViewController = [[PushViewController alloc] initWithNibName:@"PushView" bundle:[NSBundle mainBundle]];
SitViewController *sitViewController = [[SitViewController alloc] initWithNibName:@"SitView" bundle:[NSBundle mainBundle]];
TimerViewController *timerViewController = [[TimerViewController alloc] initWithNibName:@"TimerView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:runViewController animated:YES];
[runViewController release];
[self.navigationController pushViewController:pushViewController animated:YES];
[pushViewController release];
[self.navigationController pushViewController:sitViewController animated:YES];
[sitViewController release];
[self.navigationController pushViewController:timerViewController animated:YES];
[timerViewController release];
[self.navigationController pushViewController:calcViewController animated:YES];
[calcViewController release];
runViewController = nil;
pushViewController = nil;
sitViewController = nil;
timerViewController = nil;
calcViewController = nil;
}
Each time I select any of the rows in the table - all of the views come up. How do I arrange them to only open the view that it is supposed to?