我有一个 UISplitViewController
,其中 MasterViewController
和 DetailViewController
有自己的导航 Controller 。
这是我的 Storyboard:
当 MasterViewController
和 DetailViewController
均可见时(iPhone 6+ 横向和 iPad):
DetailViewController
使用详细导航 Controller
。这里的一切都很完美。
当仅 DetailViewController
可见时(iPhone 6+ 纵向和所有其他 iPhone 横向和纵向):
DetailViewController
仍然使用详细导航 Controller
(self.navigationController
返回详细导航 Controller
)。但在顶部,主导航 Controller
的导航栏是可见的,而不是详细导航 Controller
的导航栏。
我想对纵向和横向模式下的每种设备尺寸使用相同的 DetailViewController
导航栏。 (主控导航栏和详细导航栏的样式不同。)
有没有办法做到这一点,而无需声明名为 currentlyVisibleNavigationController
的黑客计算属性或保留 ViewController 之间的引用?
最佳答案
要在 UISplitViewController
上下文中获取详细 Controller 的当前 UINavigationBar
对象,您可以尝试以下操作:
let navigationBar = navigationController?.navigationController?.navigationBar ?? navigationController?.navigationBar
关于ios - 在纵向模式下更改 UISplitViewController 中详细信息的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38995514/