Systems back button on the navigation bar.
I want this system's button which is on the navigationBar has two different actions.
1. navigationController?.popViewController
when device orientation is portrait as default action.
2. rotate device orientation to portrait when device orientation is landscape. UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
I can do it by create a new UIBarButtonItem and set it to navigationItem.leftBarButtonItem
.
But it doesn't have system's left-arrow image and localize string. I need this button has system's left-arrow image and localize string likes system's provide.
I tried to set action like
navigationController?.navigationBar.backItem?.backBarButtonItem?.action = #selector(self.backToPortrait)
It wasn't work.
So how can I set action to this back button?