allpnay allpnay - 1 year ago 86
iOS Question

iOS table navcontroller not working

I have a table:

- (void)viewWillAppear:(BOOL)animated

[self.searchResultTable setHidden:YES];


In my cells I insert text and when I click on cell I need go to another table but this not work:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

TableViewController *tvc=[[TableViewController alloc]initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:tvc animated:YES];

Answer Source

Assuming you are doing something like this to present this controller:

SearchViewController *searchViewController = [SearchViewController alloc] init];
[self presentModalViewController:searchViewController animated:YES];

then your view controller doesn't have a navigation controller

You need to change it to

SearchViewController *searchViewController = [SearchViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:searchViewController];
[self presentModalViewController:navController animated:YES];

then [self.navigationController pushViewController:tvc animated:YES]; will work

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download