views:

25

answers:

0

This problem has been the dragging factor of my project for weeks now. Somebody please help me out.

I want to modally present UINavigationController that has UITableView as its rootviewcontroller. I want UITableView to be the rootview, which I can drill into other views from.

I tried this:

 SettingsViewController *addController = [[SettingsViewController alloc]                                                                                                                                                                                                   
 initWithNibName:@"SettingsViewController" bundle:nil];
 UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addController];
 [self presentModalViewController:navController animated:YES];

This lets the presented modal view show the navigation bar, tableview perfectly. But the problems is that it won't let me drill into the other views from the presented modal view.

In short, this code from the SettingsViewController doesn't work:

#pragma mark -
#pragma mark UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
   UIViewController *targetViewController = [[self.settingsList objectAtIndex: indexPath.row] objectForKey:kViewControllerKey];
   [self.navigationController pushViewController:targetViewController animated:YES];
  }

So I created SettingsNavController.h/m and tried addSubview: just like the codes that people put in AppDelegate.m when creating navigation controller just right after the application launches. And also in the IB, created window and navigationController and connected them to the File's owner accordingly.

  UINavigationController *navigationController;
UIWindow *window;

- (void)viewDidLoad {
[super viewDidLoad];

  [window addSubview:navigationController.view];
  [window makeKeyAndVisible];}

When I build this code and tries to present the modal view, the system crashes.

What should I do now?

related questions