Reputation: 711
I implemented a splitview using 2 UITableViews and a UIViewController. Showing both on the screen with their own data is working fine. Now in my DidSelectRowForIndexPath I did the following:
DetailViewController *nextController = [[DetailViewController alloc] initWithStyle:UITableViewStylePlain];
NSMutableArray *objects;
objects = [[NSMutableArray alloc] initWithObjects:@"A", @"B", nil];
nextController.title = @"Filter";
[nextController SetArray:objects];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:nextController];
[self presentModalViewController:nc animated:YES];
//used this before [self.navigationController pushViewController:nextController animated:YES];
[FilterView deselectRowAtIndexPath:indexPath animated:YES];
Upvotes: 0
Views: 320
Reputation: 1920
First you need to confirm that you have UINavigationController at base then you can pushViewController:nextController
[FilterView deselectRowAtIndexPath:indexPath animated:YES];
DetailViewController *nextController = [[DetailViewController alloc] initWithStyle:UITableViewStylePlain];
NSMutableArray *objects;
objects = [[NSMutableArray alloc] initWithObjects:@"A", @"B", nil];
nextController.title = @"Filter";
[nextController SetArray:objects];
[self.navigationController pushViewController:nextController animated:YES];
Upvotes: 0
Reputation: 3231
If you have started the app from the master/detail template while creating the project. Then it will have the navigation controller set automatically in the appDelegate didFinishLaunching
method so in the didSelect
methods you have to just use
`[self.navigationController pushViewController:vc animated:YES];`
instead of
[self presentModalViewController:nc animated:YES];
Here is a sample code which uses split view with navigation to and from root view.
Upvotes: 2