add bar button item programmatically at ViewControllers after rootView Swift 3.0

Viewed 9002

I have a View hierarchy

there is just one navigation controller and its rootViewController.

I want to add a left bar button item at the view which is circled.

the View I want to add barButton:

enter image description here

I tried

self.navigationController?.navigationItem.leftBarButtonItem = editButtonItem

in viewDidLoad() and viewWillAppear() but none of them worked out. I also tried adding UINavigationItem in storyBoard and then adding barButtonItem. this didn't work too.

EDIT

I tried the answers below and that's what I get in the output.

my output after trying answers:

enter image description here

any help would be appreciated.

2 Answers
Related