import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func moveToNexScreen(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let nextVc = storyboard.instantiateViewController(withIdentifier: "NextViewController") as! NextViewController
let navigationVc = UINavigationController(rootViewController: nextVc)
present(navigationVc, animated: false, completion: nil)
}
}
class NextViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.closeBackButtonPressed))
}
@objc func closeBackButtonPressed(){
self.dismiss(animated: false, completion: nil)
}
}
Put your detailView inside UINavigationController(rootViewController: detailVc)
and then you can present it and to have a back button you can add a barbutton item on the detailsView programatically