Search code examples
swiftuinavigationitem

Set navigation item title on a TableViewController child of UISideMenuNavigationController not working


I am trying to set a title to my rootViewController programmatically but it is not working.

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
    }

The title doesn't change.

It works when I try in another project without Side Menu on a regular UINavigationController.

enter image description here

enter image description here


Solution

  • It worked when I created a custom UITableViewController and set it as the view controller of the Table View Controller on the Storyboard.