我有一个视图控制器层次结构和最顶端的控制器显示为一个模态,并希望知道如何显示导航栏时使用
'UIViewController:presentViewController:viewControllerToPresent:animated:completion'
‘ presViewController: Animated: complete:’注意:
在 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];