我有一个视图控制器层次结构和最上面的控制器被显示为模式和想知道如何显示导航栏使用presentViewController和显示导航栏
'UIViewController:presentViewController:viewControllerToPresent:animated:completion'
关于“presentViewController该文档时:注:
'在iPhone和iPod touch上,呈现的视图始终为全屏。 在iPad上,演示文稿取决于 modalPresentationStyle属性中的值。'
对于“modalPresentationStyle”,文档说:
呈现样式决定如何一个模态呈现视图控制器在屏幕上显示。在iPhone和iPod touch上,模式视图控制器总是全屏显示,但在iPad上有几种不同的显示选项。
有没有办法确保导航栏在状态栏下方可见,一旦视图控件显示出来?我是否应该将文档解释为,您没有获得iPhone/iPod的任何选项,只能在iPad上使用?
以前,我使用的是'UIViewController:presentModalViewController:animated'
,它工作正常,但自iOS 5.0以来,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];
这几乎是我开始的。但是我没有使用'presentModalViewController'的原因是因为它被称为不赞成使用的API。 – 2012-03-15 18:22:09
这是在UIViewController类中写入的内容: //将另一个视图控制器显示为模态子项。如果使用动画,则使用垂直图纸过渡。此方法已由presentViewController取代:动画:完成: //将进行相应的计划。 (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated; 所以只需调用新方法并通过零来完成,你应该很好。 – 2012-03-15 18:24:34
很好的回答。更新为使用'(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void(^)(void))completion' – 2014-07-18 15:00:59