ENSideSwiftMenu: how to use the same navbar for all view controllers

I am using Evgeny Nazarov Swift Side Menu for my iOS app and was wondering if anyone has used this same library and could have the same navigation bar for each View Controller

invoked in the menu.

I put BarButtonItem

that toggles the sliding menu on Root View Controller

. My problem is that only mine is Root View Controller

showing this Toggle button. But I would like to have the same one Navigation Bar

with a button Toggle

on each View Controller

one that is available when you click an option in the sliding menu.

Has anyone had any experience of achieving this? Thank!

UPDATE 1

This is what happens when I added NavigationBar

and BarButtonItem

in another ViewControllers

that are not RootViewController

. The new navigation bar is located below the existing navigation bar from the navigation controller.

The screen is on the left Root View Controller

, and on the right View Controller

when I select the second item in the menu.

UPDATE 2: SOLUTION

override func viewDidLoad() {
    super.viewDidLoad()

    let menuItem = UIBarButtonItem(image: UIImage(named: "icon_menu"), style: .Plain, target: self, action: "menuBarButtonItemClicked")
    menuItem.tintColor = UIColor.whiteColor()
    self.navigationItem.leftBarButtonItem = menuItem
}

func menuBarButtonItemClicked() {
    toggleSideMenuView()
}

      

enter image description here

+3


source to share


2 answers


You need to put the UIBarButtonItem on the navbar in each view controller, not the root view controller.



0


source


I also used the same design for their application, and I solved it this way: See every sect " Show Attributes Inspector β†’ Top panel " voice " Clear navigation bar " and then drag the " Navigation Element ", and then " buttons panel element " in the right place. Of course, each button must have its own code or links to the ViewController. Let me know if you have decided.



0


source







All Articles