问题描述
我的 Swift 项目中有以下 Storyboard Segue:
I have the following Storyboard Segue in my Swift project:
动画是正确的,但是目标视图控制器中没有导航栏.我想强制目标视图控制器有一个导航栏.我在目标视图控制器中尝试过:
The animation is correct, but there is no navigation bar in the destination view controller. I want to force the destination view controller to have a navigation bar. I tried in the destination view controller:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
navigationController?.navigationBar.hidden = false
}
或者:
override func viewWillAppear(animated: Bool) {
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
但它拒绝显示任何导航栏.
But it refuses to show any navigation bar.
如何执行垂直转场(如Cover Vertical")但仍然在目标视图控制器中显示半透明导航栏?
How can I perform a vertical segue (like "Cover Vertical") but still display a translucent Navigation bar in the destination view controller?
目标视图控制器的我的属性检查器:
My Attributes inspector for the destination view controller:
推荐答案
尝试将 Segue 创建到导航控制器而不是您的视图控制器.导航栏仅针对导航堆栈中的视图控制器显示.在您的情况下,源视图控制器似乎在导航堆栈中,但不在呈现的视图控制器中.尝试这样的事情:
Try to create the Segue to a Navigation controller instead of your view controller. Navigation bars are only shown for view controllers in a navigation stack. In your case, the source view controller seems to be in a navigation stack but not the presented view controller. Try something like this:
这篇关于Swift:在模态中强制显示导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!