0

I'm trying to create a container view controller (see screenshot) and I would like to add a navigation controller at the right, but I'm having some problems. Can you help me?

When I add this code in my parent controller (viewDidLoad), I see the view with other position/size, I guess because I can't access navigation controller container view.

Tried:

[self addChildViewController:_detailNavigationController];
_detailNavigationController.view.frame = CGRectMake(256, 49, 768, 651);
[self.view addSubview:_detailNavigationController.view];

And also this, but only works with the first view, evidently.

[self addChildViewController:_detailNavigationController];
_detailNavigationController.topViewController.view.frame = CGRectMake(256, 49, 768, 651);
[self.view addSubview:_detailNavigationController..topViewController.view];

Tried a hack to get navigation controller container view, but doesn't work, I see nothing on the screen and using the debugger I realized view is nil. Apart from that, likely Apple don't like this.

[self addChildViewController:_detailNavigationController];
UIView *view = [_detailNavigationController valueForKey:@"_containerView"];
view.frame = CGRectMake(256, 49, 768, 651);
[self.view addSubview:view];

Am I missing something?
Do you know how I can add a navigation controller inside my own customized container view controller?
Thanks in advance!

Screenshot: http://img803.imageshack.us/img803/2464/screennjz.png

Ricardo
  • 2,831
  • 4
  • 29
  • 42

1 Answers1

1

I have custom classes MasterViewController and DetailedViewController are subclasses of UITableViewController. NavigationController is a subclass of UINavigationController and SplitViewController is a subclass of UISplitViewController.

As you can see it works but I am having a problem when I pop a view from the navigation controller. If you find out how to fix this let me know.

enter image description here

    MasterViewController *master = [[MasterViewController alloc] init];

    NavigationController *masterNav = [[NavigationController alloc] initWithRootViewController:master];

    DetailedViewController *detailed = [[DetailedViewController alloc] init];

    NavigationController *detailedNav = [[NavigationController alloc] initWithRootViewController:detailed];

    myVC = [[SplitViewController alloc] init];

    [myVC setViewControllers:[NSArray arrayWithObjects:masterNav, detailedNav, nil]];
Ste Prescott
  • 1,789
  • 2
  • 22
  • 43