Answers for "show alert when user tries to go back navigation controller swift 5"

1

xcode execute code after when navigating back to screen

// Use this if you don't want to override the navigation style, text, etc.
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    if self.isMovingFromParent {
        // Your code...
    }
}
Posted by: Guest on September-02-2020
0

xcode execute code after when navigating back to screen

// Use this to override the navigation bar's default back button
	override func viewDidLoad {
        super.viewDidLoad()
        self.navigationItem.hidesBackButton = true
        let newBackButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.plain, target: self, action: #selector(YourViewController.back(sender:)))
        self.navigationItem.leftBarButtonItem = newBackButton
    }

    @objc func back(sender: UIBarButtonItem) {
        // Perform your custom actions
        // ...
        // Go back to the previous ViewController
        _ = navigationController?.popViewController(animated: true)
    }
Posted by: Guest on September-02-2020

Code answers related to "show alert when user tries to go back navigation controller swift 5"

Code answers related to "Swift"

Browse Popular Code Answers by Language