I have a NavigationViewController which root is a regular UIViewController. I present a TableViewController programatically by:
self.performSegue(withIdentifier: "showTableViewVC", sender: nil)
This TableViewVC is showing the BACK button but it is not working at all.
The segue to this TableViewVC is a "show/push" segue.
How to navigate back to the UIViewController?
1. Add a UIBarbutton into navigation controller in showTableViewVC.
override func viewDidLoad() {
super.viewDidLoad()
let backBarButton = UIBarButtonItem.init(barButtonSystemItem: .add, target: self, action: #selector(backButtonTapped(sender:))) as UIBarButtonItem
self.navigationItem.setLeftBarButton(backBarButton, animated: true)
}
2. Implement back button Action.
func backButtonTapped(sender: UIBarButtonItem)
{
self.navigationController?.popViewController(animated: true)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.