Programmatically go back to previous ViewController in Swift

前端 未结 15 1536
野的像风
野的像风 2020-12-04 04:50

I send the user over to a page on a button click. This page is a UITableViewController.

Now if the user taps on a cell, I would like to push him ba

15条回答
  •  粉色の甜心
    2020-12-04 05:38

    I did it like this

    func showAlert() {
        let alert = UIAlertController(title: "Thanks!", message: "We'll get back to you as soon as posible.", preferredStyle: .alert)
    
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
            self.dismissView()
        }))
    
        self.present(alert, animated: true)
    }
    
    func dismissView() {
        navigationController?.popViewController(animated: true)
        dismiss(animated: true, completion: nil)
    }
    

提交回复
热议问题