[英]Changing Detail's Navigation Bar in UISplitViewController in Portrait mode
I have a UISplitViewController
in which MasterViewController
and DetailViewController
has its own navigation controller.我有一个UISplitViewController
,其中MasterViewController
和DetailViewController
有自己的导航控制器。
This is my storyboard:这是我的故事板:
When MasterViewController
and DetailViewController
are both visible (iPhone 6+ Landscape and iPad):当MasterViewController
和DetailViewController
都可见时(iPhone 6+ Landscape 和 iPad):
DetailViewController
uses Detail Navigation Controller
. DetailViewController
使用Detail Navigation Controller
。 Everything is perfect in here.这里的一切都很完美。
When only DetailViewController
is visible (iPhone 6+ Portrait and all other iPhones both Landscape and Portrait):当只有DetailViewController
可见时(iPhone 6+ 纵向和所有其他 iPhone 横向和纵向):
DetailViewController
still uses Detail Navigation Controller
( self.navigationController
returns Detail Navigation Controller
). DetailViewController
仍然使用Detail Navigation Controller
( self.navigationController
返回Detail Navigation Controller
)。 But on top, Master Navigation Controller
's navigation bar is visible, instead of Detail Navigation Controller
's navigation bar.但最重要的是, Master Navigation Controller
的导航栏是可见的,而不是Detail Navigation Controller
的导航栏。
I want to use same navigation bar for DetailViewController
for every device size in both portrait and landscape mode.我想在纵向和横向模式下为每个设备尺寸使用相同的DetailViewController
导航栏。 (Styling for master's navigation bar and detail's navigation bar is different.) (master 导航栏和detail 导航栏的样式不同。)
Is there a way to do this without declaring a hacky computed property named currentlyVisibleNavigationController
or keeping references between ViewControllers?有没有办法做到这一点不宣名为哈克计算财产currentlyVisibleNavigationController
或ViewControllers之间保持引用?
要在UISplitViewController
上下文中获取详细信息控制器的当前UINavigationBar
对象,您可以尝试以下操作:
let navigationBar = navigationController?.navigationController?.navigationBar ?? navigationController?.navigationBar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.