0

I am putting a UINavigationController inside a container view like so (this in a full screen UIViewController subclass):

  UIViewController *litteViewController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
  UINavigationController *littleNavigator = [[UINavigationController alloc]initWithRootViewController:litteViewController];

  UIView *containerView = [[UIView alloc]initWithFrame:CGRectMake(100.0, 100.0, 250.0, 320.0)];
  littleNavigator.view.frame = containerView.bounds;

  [self addChildViewController:littleNavigator];

  [containerView addSubview:littleNavigator.view];
  [self.view addSubview:containerView];

  [littleNavigator didMoveToParentViewController:self];

Now this works as expected and littleViewController appears in the rect I expect with a nav bar at top. Now let us say as a result of some interaction inside littleViewController something like this happens

 -(void)someButtonAction:(id)sender{

       UIViewController *secondLittleViewController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
       [self.navigationController presentModalViewController:secondLittleViewController animated:YES];
}

unfortunately this subsequent controller winds up being presented full screen. Now I've done exactly this before inside popoverControllers and splitViewControllers and they've behaved exactly as I want this to, a navigation stack is built within the little rectangle it was started in.

How can I build a navigation stack inside a container over in an arbitrary CGRect?

4
  • iPhone or iPad? iOS version? Commented Sep 14, 2014 at 14:12
  • thanks mate. the code I'm looking for should work on any iOs device >= iOs5 (which is where the addChildViewConroller: stuff is) Commented Sep 14, 2014 at 14:16
  • On iPhone and iPod touch, the presented view is always full screen. So you need change to pushViewController Commented Sep 14, 2014 at 14:36
  • Oh yeah! wow thanks can't believe i forgot that one. thanks so much make it an answer will you? Commented Sep 14, 2014 at 14:41

1 Answer 1

1

On iPhone and iPod touch, the presented view is always full screen. So you need change to pushViewController

Glad I can help

Sign up to request clarification or add additional context in comments.

1 Comment

YEP!! thanks mate. pushViewController: animated: has been there forever and i don't think Ive ever really needed it. Thanks so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.