0

的孩子,我不知道,如果标题说明了问题本身,但在这里它是...的UINavigationController作为UINavigationController的

我有一个UINavigationController这是一个UINavigationController的parentViewController。事情是childViewController的行为很奇怪,当我将它作为一个孩子添加它时,它首先与statusBar有差距(它不占用整个屏幕),如果我通过隐藏和显示navigationBar来“解决”该“bug”差距消失,但现在孩子不尊重我手动设置的框架。 然后,我试图继续,当我提出一个模式的孩子和解雇它,整个孩子消失...

那里会有什么错?与这两个容器的父子关系还是什么?

感谢咨询

编辑:这里是展示奇怪的行为

实例项目

http://www.mediafire.com/?8saa68daqfkf335

编辑2:我找到了解决办法其实,我并没有找到苹果文档真的清楚,它说childViewControllers从它们属于的parentViewController获取框架,但是它并没有说如果parentViewController“重新出现”(就像在它上面推),childViewControllers会被parentViewController框架再次调整大小...希望这有助于任何人

+0

也许你可以提供一个截图(或两个,...) – 2013-03-22 14:23:48

+0

好吧给我一个秒...编辑:嗯,我实际上只能发布UINavigationController作为孩子的差距的图像,但其他行为不能像这样的截图...让我附上一个示例项目,显示“bug”的东西... – 2013-03-22 14:24:11

+0

容器内的容器,我认为这不是一个好方法,也许你需要尝试一个自定义控制器父母导航控制器... PS chupili – D33pN16h7 2013-03-22 16:38:04

回答

0

我相信将第二个导航视图控制器作为模式视图控制器会更好。 例如,对于像替换当前presentController选择:

- (void)presentController:(id)sender { 

ChildViewController1 *cvc = [[ChildViewController1 alloc] initWithNibName:@"ChildViewController1" bundle:nil]; 
nc3 = [[UINavigationController alloc] initWithRootViewController:cvc]; 

nc3.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 

[self presentViewController:nc3 animated:YES completion:nil]; 

UIBarButtonItem *i = [[UIBarButtonItem alloc] initWithTitle:@"X" style:UIBarButtonItemStyleBordered target:self action:@selector(close)]; 
cvc.navigationItem.leftBarButtonItem = i; 
} 

然后,你的亲密选择将变成:

- (void)close { 
[nc3 dismissViewControllerAnimated:YES completion:nil]; 
} 

(虽然我建议移动按钮的创建和处理实际上在ChildViewController1.m中关闭)。

当然,这将需要导航控制器的所有创作过ViewController.m的viewDidLoad选择:

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.view.backgroundColor = [UIColor blueColor]; 

UIButton *b = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
b.frame = CGRectMake(0, 100, 100, 40); 
[b setTitle:@"present" forState:UIControlStateNormal]; 
[b addTarget:self action:@selector(presentController:) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:b]; 
} 

希望工程!

+0

事情是我需要childViewController始终在那里,因为它有一个UIPanGestureRecognizer,让您滑动控制器到顶部呈现它... – 2013-03-22 16:23:27

+0

我同意D33pN16h7,另一个UINavigationController的rootViewController内的UINavigationController不会听起来像是最好的方法。 也许你可以截取第二个导航控制器的截图来呈现和使用该屏幕截图进行滑动运动,那么当幻灯片完成后,您可以不使用动画呈现您的辅助导航控制器?在避免嵌套UINavigationControllers的同时,你会保持幻觉。 – Pablo 2013-03-22 18:50:24