1

I have two view controllers.

The first one is embedded in a Navigation Controller. On the first view controller there is Bar Button Item which is connected by a segue to the second view controller. The segue is set as Push. Once I go to the second view controller there is a Bar Button Item which is an IBAction and should dismiss the page, but it doesn't.

Second View Controller Code:

import UIKit

class Page2ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    @IBAction func donePressed(_ sender: Any) {
        dismiss(animated: true, completion: nil)
    }

}

1 Answers1

3

Within your donePressed(_:) function, access the navigation controller and call the popViewController(_:) function.

@IBAction func donePressed(_ sender: Any) {
     navigationController?.popViewController(animated: true)
}
AnthonyC
  • 48
  • 6