0
我想以編程方式爲我的rootViewController設置標題,但它不工作。在UISideMenuNavigationController的TableViewController子項上設置導航項目標題不起作用
func configurarMenuRightNavigationController() {
SideMenuManager.menuFadeStatusBar = false
let menuRightNavigationController = storyboard!.instantiateViewController(withIdentifier: "RightMenuNavigationController") as! UISideMenuNavigationController
//let menuRightNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
// UISideMenuNavigationController is a subclass of UINavigationController, so do any additional configuration
// of it here like setting its viewControllers. If you're using storyboards, you'll want to do something like:
SideMenuManager.menuRightNavigationController = menuRightNavigationController
SideMenuManager.menuRightNavigationController?.viewControllers[0].navigationItem.title = "Teste"
SideMenuManager.menuPresentMode = .viewSlideOut
}
標題不變。
它工作時,我嘗試在另一個沒有常規UINavigationController側面菜單項目。
我懷疑問題是你正試圖改變一個全新創建的導航控制器上的標題,該控制器*沒有任何視圖控制器*。如果你做''如果讓topViewController = SideMenuManager.menuRightNavigationController?.viewControllers [0]'「,然後打印出來的東西(或設置一個斷點),如果'topViewController'不是零,它打? –
是的,我想過,但我無法實例化正確的控制器。我怎麼能這樣做? – GuiDupas