我有一个视图控制器层次结构,最顶层的控制器显示为模式,并想知道在使用时如何显示导航栏
'UIViewController:presentViewController:viewControllerToPresent:animated:completion'
“ presentViewController:animated:completion:”的文档请注意:
'在iPhone和iPod touch上,显示的视图始终为全屏。在iPad上,演示文稿取决于modalPresentationStyle属性中的值。
对于'modalPresentationStyle',文档说:
呈现样式决定了模态呈现的视图控制器如何在屏幕上显示。在iPhone和iPod touch上,模态视图控制器始终以全屏显示,但在iPad上有几种不同的显示选项。
一旦视图控件显示自身,是否有办法确保导航栏在状态栏下方可见?我应该将文档解释为,您没有iPhone / iPod的任何选项,而只有iPad?
以前,我使用的工具'UIViewController:presentModalViewController:animated'
运行良好,但是自iOS 5.0以来,该API已被弃用,因此我将切换到新的API。
从视觉上看,我想要做的是从屏幕底部插入新的控制器幻灯片,就像以前使用的旧API一样。
[使用代码更新]:
// My root level view:
UIViewController *vc = [[RootViewController alloc]
initWithNibName:nil
bundle:[NSBundle mainBundle]];
navController = [[UINavigationController alloc] initWithRootViewController:vc];
....
// Within the RootViewController, Second view controller is created and added
// to the hierarchy. It is this view controller that is responsible for
// displaying the DetailView:
SecondTierViewController *t2controller = [[SecondTierViewController alloc]
initWithNibName:nil
bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:t2controller animated:YES];
// Created by SecondTierViewController
DetailViewController *controller = [[DetailViewController alloc] initWithNibName:nil
bundle:[NSBundle mainBundle]];
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
controller.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:controller
animated:YES
completion:nil];