I have two view controllers, I added navigation bar
to second view controller
with two bar button items Back
and Item
as shown below
But when I do a push segue
from first view controller
, it is replaced by navigation item <Category
, which is title
of navigation item
in my first view controller
as shown below
How do I keep my navigation bar
intact avoiding the default navigation item <Category
, which is being added automatically while maintaining push segue functionality.
I tried to do maually without using stoyboard as follows
@IBAction func plusAction(_ sender: Any) {
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SVC") as? SecondViewController
self.navigationController?.pushViewController(secondViewController!, animated: true)
}
but it still doesnt work.
You want to display two bar button items Back
and Item
by added UINavigationBar
to second view controller, you are doing it in the wrong way!!!
In your storyboard, drag a UINavigationItem
to your second ViewController.
If the
UINavigationItem
does not display on your storyboard, you must select second view controller, chooseOpaque Navigation Bar
orTranslucent Navigation Bar
(not important)
After that, you can drag UIBarButtonItem
where you want on your ViewController