我正在UINavigationController
像这样在容器视图中放置一个(这在全屏UIViewController
子类中):
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];
现在这可以按预期工作,并littleViewController
出现在我期望的矩形中,顶部有一个导航栏。现在让我们说由于内部的一些交互,littleViewController
发生了这样的事情
-(void)someButtonAction:(id)sender{
UIViewController *secondLittleViewController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
[self.navigationController presentModalViewController:secondLittleViewController animated:YES];
}
不幸的是,这个后续的控制器最终会全屏显示。现在我在里面已经完全做到了这一点popoverControllers
,splitViewControllers
并且它们的行为与我想要的完全一样,导航堆栈构建在它开始的小矩形内。
如何在任意 CGRect 中的容器内构建导航堆栈?