DanielR
DanielR

Reputation: 711

How to drill down and show detail uitableview with splitview without storyboard

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];
  1. Maybe you know a better method as what I did to present the nextController
  2. The nextController is always showing up from the bottom and moving to the top. How can I accomplish this default sliding animation where the detail view comes into the view from the right side?

Upvotes: 0

Views: 320

Answers (2)

prashant
prashant

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

vishy
vishy

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

Related Questions